|
- <?php
-
- namespace App\Jobs\Other\Custom\HelloTechno;
-
- use App\Codes\QueueName;
- use App\Jobs\BaseJob;
- use App\Models\ReceiptIssuingHTParkingCustomOrder;
- use App\Models\ReceiptIssuingOrder;
- use App\Models\ReceiptIssuingOrderTax;
- use App\Util\Custom\HelloTechno\API;
- use Illuminate\Support\Carbon;
-
- class NoticeReceiptIssuingOrder extends BaseJob
- {
- /**
- * Create a new job instance.
- *
- * @return void
- */
- public function __construct(
- private ReceiptIssuingOrder $order,
- private ReceiptIssuingHTParkingCustomOrder $custom,
- private ReceiptIssuingOrderTax $tax,
- private string $eventName,
- private Carbon $eventDatetime,
- ) {
- $this->onQueue(QueueName::JOB->value);
- }
-
- /**
- * Execute the job.
- *
- * @return void
- */
- public function handle()
- {
- try {
- API::sendReceiptIssuingOrder($this->order, $this->custom, $this->tax, $this->eventName, $this->eventDatetime);
- } 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);
- }
- }
- }
|