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

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