|
- <?php
-
- namespace App\Jobs\Other\Custom\HelloTechno;
-
- use App\Codes\QueueName;
- use App\Models\ReceiptIssuingHTParkingCustomOrder;
- use App\Models\ReceiptIssuingOrder;
- use App\Util\Custom\HelloTechno\API;
- use Illuminate\Bus\Queueable;
- use Illuminate\Contracts\Queue\ShouldQueue;
- use Illuminate\Foundation\Bus\Dispatchable;
- use Illuminate\Queue\InteractsWithQueue;
- use Illuminate\Queue\SerializesModels;
-
- class NoticeReceiptIssuingOrder implements ShouldQueue
- {
- use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
-
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(
- private ReceiptIssuingOrder $order,
- private ReceiptIssuingHTParkingCustomOrder $custom,
- private string $eventName = "",
- ) {
- $this->onQueue(QueueName::JOB->value);
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- try {
- API::sendReceiptIssuingOrder($this->order, $this->custom);
- } catch (Exception $e) {
- $this->log(false);
- throw $e;
- }
-
- $this->log(true);
- }
-
- public function log(bool $success)
- {
- $log = sprintf(
- "[HelloTechno]領収証発行依頼情報送信[%s] %s ID:%s C:%s P:%s A:%d",
- $this->eventName,
- $success ? "成功" : "失敗",
- $this->order->id,
- $this->custom->customer_name,
- $this->custom->parking_name,
- $this->custom->adjust_seq_no ?? 0,
- );
-
- if ($success) {
- logs()->info($log);
- } else {
- logs()->error($log);
- }
- }
- }
|