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

62 line
1.4KB

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