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.

52 lines
1.3KB

  1. <?php
  2. namespace App\Http\Controllers\Web\QRService\Acquisition;
  3. use App\Http\Controllers\Web\WebController;
  4. use App\Logics\QRService\QRCryptoLogic;
  5. use App\Models\HtpmsCustomer\QRService\AcquisitionTicketToken;
  6. use Illuminate\Http\JsonResponse;
  7. use Illuminate\Http\Request;
  8. use Str;
  9. class GetAcquisitionTokenController extends WebController
  10. {
  11. public function name(): string
  12. {
  13. return "サービス券取得用トークン取得";
  14. }
  15. public function description(): string
  16. {
  17. return "サービス券取得用トークンを取得する";
  18. }
  19. public function __construct(protected GetAcquisitionTokenParam $param)
  20. {
  21. parent::__construct();
  22. }
  23. protected function run(Request $request): JsonResponse
  24. {
  25. $shopId = $this->sessionUser->shopId();
  26. $token = AcquisitionTicketToken::whereShopId($shopId)->first();
  27. if ($token === null) {
  28. $token = new AcquisitionTicketToken();
  29. $token->shop_id = $shopId;
  30. $token->token = Str::uuid()->toString();
  31. $token->save();
  32. }
  33. $res = [
  34. "token" => $token->token,
  35. "customer_id" => $this->sessionUser->customerId(),
  36. ];
  37. return $this->successResponse($res);
  38. }
  39. }