|
- <?php
-
- namespace App\Http\Controllers\Web\Shop;
-
- use App\Http\Controllers\Web\WebController;
- use App\Logics\QRService\ChargeLogic;
- use Illuminate\Http\JsonResponse;
- use Illuminate\Http\Request;
- use LogicException;
-
- class DepositChargeController extends WebController
- {
-
- public function name(): string
- {
- return "デポジットチャージ";
- }
-
- public function description(): string
- {
- return "デポジットをチャージする";
- }
-
-
- public function __construct(protected DepositChargeParam $param, protected ChargeLogic $logic)
- {
- parent::__construct();
- }
-
- protected function run(Request $request): JsonResponse
- {
- $param = $this->param;
-
- $user = $this->sessionUser->user();
- if ($user instanceof null) {
- throw new LogicException();
- }
-
- if ($user->shop_id === null) {
- throw new LogicException();
- }
-
-
- $deposit = $this->logic->charge($user->shop_id, $param->amount);
-
- $res = [
- "shop_id" => $deposit->shop_id,
- "deposit" => $deposit->deposit,
- ];
-
- return $this->successResponse($res);
- }
- }
|