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

66 lines
1.6KB

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