領収証発行サービス
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.

68 lines
1.7KB

  1. <?php
  2. namespace App\Jobs\Other\Custom\HelloTechno;
  3. use App\Codes\QueueName;
  4. use App\Models\ReceiptIssuingHTParkingCustomOrder;
  5. use App\Models\ReceiptIssuingOrder;
  6. use App\Util\Custom\HelloTechno\API;
  7. use Illuminate\Bus\Queueable;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use Illuminate\Queue\InteractsWithQueue;
  11. use Illuminate\Queue\SerializesModels;
  12. class NoticeReceiptIssuingOrder implements ShouldQueue
  13. {
  14. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  15. /**
  16. * Create a new job instance.
  17. *
  18. * @return void
  19. */
  20. public function __construct(
  21. private ReceiptIssuingOrder $order,
  22. private ReceiptIssuingHTParkingCustomOrder $custom,
  23. private string $eventName = "",
  24. ) {
  25. $this->onQueue(QueueName::JOB->value);
  26. }
  27. /**
  28. * Execute the job.
  29. *
  30. * @return void
  31. */
  32. public function handle()
  33. {
  34. try {
  35. API::sendReceiptIssuingOrder($this->order, $this->custom);
  36. } catch (Exception $e) {
  37. $this->log(false);
  38. throw $e;
  39. }
  40. $this->log(true);
  41. }
  42. public function log(bool $success)
  43. {
  44. $log = sprintf(
  45. "[HelloTechno]領収証発行依頼情報送信[%s] %s ID:%s C:%s P:%s A:%d",
  46. $this->eventName,
  47. $success ? "成功" : "失敗",
  48. $this->order->id,
  49. $this->custom->customer_name,
  50. $this->custom->parking_name,
  51. $this->custom->adjust_seq_no ?? 0,
  52. );
  53. if ($success) {
  54. logs()->info($log);
  55. } else {
  56. logs()->error($log);
  57. }
  58. }
  59. }