領収証発行サービス
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

60 lines
1.7KB

  1. <?php
  2. namespace App\Jobs\Other\Custom\HelloTechno;
  3. use App\Codes\QueueName;
  4. use App\Jobs\BaseJob;
  5. use App\Logic\SMS\SMSManager;
  6. use App\Models\HtCustomParkingName;
  7. use App\Util\Custom\HelloTechno\API;
  8. class CacheParkingName extends BaseJob
  9. {
  10. /**
  11. * Create a new job instance.
  12. *
  13. * @return void
  14. */
  15. public function __construct(
  16. private string $customerCode,
  17. private string $parkingManagementCode
  18. ) {
  19. $this->onQueue(QueueName::JOB->value);
  20. }
  21. /**
  22. * Execute the job.
  23. *
  24. * @return void
  25. */
  26. public function handle(SMSManager $manager)
  27. {
  28. // 顧客情報取得
  29. $customer = collect(API::getCustomers($this->customerCode))
  30. ->where('customer_code', $this->customerCode)
  31. ->firstOrFail();
  32. // 駐車場情報取得
  33. $parking = collect(API::getParkings([
  34. API::CONDITION_CUSTOMER_CODDE => $this->customerCode,
  35. API::CONDITION_PARKING_MANAGEMENT_CODDE => $this->parkingManagementCode,
  36. ]))
  37. ->where('parking_management_code', $this->parkingManagementCode)
  38. ->firstOrFail();
  39. // モデル更新
  40. $model = HtCustomParkingName::whereCustomerCode($this->customerCode)
  41. ->whereParkingManagementCode($this->parkingManagementCode)
  42. ->firstOrNew([
  43. HtCustomParkingName::COL_NAME_CUSTOMER_CODE => $this->customerCode,
  44. HtCustomParkingName::COL_NAME_PARKING_MANAGEMENT_CODE => $this->parkingManagementCode,
  45. ]);
  46. $model->customer_name = $customer['name'];
  47. $model->parking_name = $parking['parking_name'];
  48. $model->save();
  49. }
  50. }