Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

54 lines
1.2KB

  1. <?php
  2. namespace App\Http\Controllers\Web\Shop;
  3. use App\Http\Controllers\Web\WebController;
  4. use App\Logics\QRService\ChargeLogic;
  5. use Illuminate\Http\JsonResponse;
  6. use Illuminate\Http\Request;
  7. use LogicException;
  8. class DepositChargeController extends WebController
  9. {
  10. public function name(): string
  11. {
  12. return "デポジットチャージ";
  13. }
  14. public function description(): string
  15. {
  16. return "デポジットをチャージする";
  17. }
  18. public function __construct(protected DepositChargeParam $param, protected ChargeLogic $logic)
  19. {
  20. parent::__construct();
  21. }
  22. protected function run(Request $request): JsonResponse
  23. {
  24. $param = $this->param;
  25. $user = $this->sessionUser->user();
  26. if ($user instanceof null) {
  27. throw new LogicException();
  28. }
  29. if ($user->shop_id === null) {
  30. throw new LogicException();
  31. }
  32. $deposit = $this->logic->charge($user->shop_id, $param->amount);
  33. $res = [
  34. "shop_id" => $deposit->shop_id,
  35. "deposit" => $deposit->deposit,
  36. ];
  37. return $this->successResponse($res);
  38. }
  39. }