diff --git a/app/Controller/Payment/AccountController.php b/app/Controller/Payment/AccountController.php index c77d51a..4a2772a 100644 --- a/app/Controller/Payment/AccountController.php +++ b/app/Controller/Payment/AccountController.php @@ -115,7 +115,11 @@ class AccountController extends AbstractController { $userInfo = $this->checkUser($request); $userId = $this->resetUserId($userInfo['userId']); - $requestLog = $this->createRequestLog(['userId' => $userId]); + $bankCard = BankCard::where('id', $request->input('id', 0))->first(); + if (!$bankCard || $bankCard->user_id != $userId) { + throw new BusinessException('银行卡不存在'); + } + $requestLog = $this->createRequestLog(['userId' => $userId, 'agreementNo' => $bankCard->agreement_no]); $result = $this->userService->unbindCard($requestLog->getData(), $requestLog->app); return $this->success(['result' => $result]); } @@ -175,7 +179,7 @@ class AccountController extends AbstractController $account = Account::where('id', $userInfo['userId'])->first(); $userId = $this->resetUserId($userInfo['userId']); $user = User::where('user_id', $userId)->first(['realname_flag', 'bind_card_flag', 'set_pwd_flag', 'mobile', 'real_name', 'certificate_no', 'user_type', 'apply_no', 'is_platform_account']); - $bankCard = BankCard::where('user_id', $userId)->first(['bank_name', 'card_user_name']); + $bankCard = BankCard::where('user_id', $userId)->first(['id', 'bank_name', 'card_user_name']); return $this->success(['username' => $account->username, 'userInfo' => $user, 'bankCard' => $bankCard]); } diff --git a/public/account.html b/public/account.html index c548806..b64e8f1 100644 --- a/public/account.html +++ b/public/account.html @@ -66,6 +66,7 @@ is_platform_account: '' }, bankCard: { + id: 0, bank_name: '', card_user_name: '' } @@ -165,7 +166,7 @@ console.log('submit!'); }, unbindCard() { - axios.post('/account/unbind-card', {token: window.sessionStorage.getItem('token')}) + axios.post('/account/unbind-card', {token: window.sessionStorage.getItem('token'), id: this.bankCard.id}) .then( (response) => { console.log(response); let result = response.data