From 41dc0c9452389b5a466a87c8f40a613dcd289b18 Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Thu, 25 Aug 2022 06:00:24 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=EA=B3=84=EC=A2=8C=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/components/view.component.html | 35 ++- .../member/user/components/view.component.ts | 211 +++++++++++++----- .../services/member_bank_account.service.ts | 13 +- 3 files changed, 188 insertions(+), 71 deletions(-) diff --git a/src/app/modules/admin/member/user/components/view.component.html b/src/app/modules/admin/member/user/components/view.component.html index b89f0a9..e7b4f2b 100644 --- a/src/app/modules/admin/member/user/components/view.component.html +++ b/src/app/modules/admin/member/user/components/view.component.html @@ -356,24 +356,43 @@
- - 환전비밀번호 + + 환전 비밀번호 - + + 환전 비밀번호 확인 + + +
+ +
+
+
+ 은행명 {{ bank.getName() }} @@ -387,9 +406,7 @@ 은행명은 필수 입력입니다. --> -
-
- + 계좌번호 - + 예금주 (this.banks = result.getBanksList())); + this._bankService.listBanks().then((result) => { + this.memberBankForm.get('bankName')?.value; + + this.memberBankForm.patchValue({ + bankName: this.currentMember?.getBankAccount()?.getBank()?.getName(), + accountNumber: this.currentMember?.getBankAccount()?.getAccountNumber(), + accountHolder: this.currentMember?.getBankAccount()?.getName(), + description: this.currentMember?.getBankAccount()?.getMemo(), + }); + + this._changeDetectorRef.markForCheck(); + + this.banks = result.getBanksList(); + }); this._activatedRoute.data.subscribe((data) => { let member: GetMemberResponse.Result = data['member']; @@ -318,10 +336,9 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { signinPw: '', exchangePw: '', mobilePhoneNumber: this.currentMember?.getMobilePhoneNumber(), - levelName: this.currentMember?.getMemberLevel()?.getId(), + levelName: this.currentMember?.getMemberLevel()?.getName(), state: this.currentMember?.getState(), nickname: this.currentMember?.getNickname(), - bankId: this.currentMember?.getBankAccount()?.getId(), }); // Mark for check this._changeDetectorRef.markForCheck(); @@ -382,55 +399,11 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { switch (this.selectedPanel) { case 'accountInfo': - { - const { - username, - signinPw, - nickname, - ownCash, - mobilePhoneNumber, - levelName, - state, - isExcahngeMoney, - comp, - coupon, - siteUrl, - hodingGameMoney, - } = this.memberDefaultForm.value; - - if (!!levelName && levelName !== '') { - const level = this.memberLevels.find( - (v) => v.getName() === levelName - ); - if (!!level) req.setMemberLevelId(level?.getId()); - } - if (!!mobilePhoneNumber && mobilePhoneNumber !== '') { - req.setMobilePhoneNumber(mobilePhoneNumber); - } - if (!!siteUrl && siteUrl !== '') { - const site = this.sites.find((v) => v.getUrl() === siteUrl); - if (!!site) req.setSiteId(site.getId()); - } - } + this.modifyMemberDefaultInfo(); break; case 'bankInfo': - { - if (!this.memberBankForm.valid) { - return; - } - const { exchangePw, accountHolder, accountNumber, description } = - this.memberBankForm.value; - - const bank = new UpdateMemberRequest.BankAccount(); - const bankId = this.currentMember?.getBankAccount()?.getId(); - if (!!bankId) { - bank.setId(bankId); - bank.setAccountNumber(accountNumber); - bank.setName(accountHolder); - } - req.setBankAccount(bank); - } + this.modifyMemberBankAccountInfo(); break; case 'settleInfo': @@ -442,11 +415,93 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { default: break; } - this._memberService.updateMember(req).then((result) => { - console.log(result); - }); } + private modifyMemberDefaultInfo(): void { + if (!this.currentMember?.getId()) { + return; + } + + const req = new UpdateMemberRequest(); + req.setId(this.currentMember?.getId()); + + const { + username, + signinPw, + nickname, + ownCash, + mobilePhoneNumber, + levelName, + state, + isExcahngeMoney, + comp, + coupon, + siteUrl, + hodingGameMoney, + } = this.memberDefaultForm.value; + + if (!!levelName && levelName !== '') { + const level = this.memberLevels.find((v) => v.getName() === levelName); + if (!!level) req.setMemberLevelId(level?.getId()); + } + if (!!mobilePhoneNumber && mobilePhoneNumber !== '') { + req.setMobilePhoneNumber(mobilePhoneNumber); + } + if (!!siteUrl && siteUrl !== '') { + const site = this.sites.find((v) => v.getUrl() === siteUrl); + if (!!site) req.setSiteId(site.getId()); + } + + this._memberService + .updateMember(req) + .then((result) => { + console.log(result); + this.showAlert('success', '수정이 완료되었습니다.'); + }) + .catch((resson) => { + this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + + private modifyMemberBankAccountInfo(): void { + if (!this.memberBankForm.valid) { + return; + } + const { + exchangePw, + exchangePwConfirm, + bankName, + accountHolder, + accountNumber, + description, + } = this.memberBankForm.value; + + const bankId = this.currentMember?.getBankAccount()?.getId(); + const bankReq = new UpdateMemberBankAccountRequest(); + const bankFind = this.banks.find((v) => v.getName() === bankName); + + if (!bankId || !bankFind) { + console.log('Error bankId undefined or bankFind undefined'); + return; + } + + bankReq.setAccountNumber(accountNumber); + bankReq.setBankId(bankFind?.getId()); + bankReq.setId(bankId); + bankReq.setMemo(description); + bankReq.setName(accountHolder); + + this._memberBankAccountService + .updateMemberBankAccount(bankReq) + .then((result) => { + this.showAlert('success', '수정이 완료되었습니다.'); + }) + .catch((reson) => { + this.showAlert('error', '수정 실패 잠시 후 다시 시도하세요.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } /** * Navigate to the panel * @@ -525,6 +580,49 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { }); } + __changeExcahngePassword(): void { + const password = this.memberBankForm.get('exchangePw')?.value as string; + const passwordConfirm = this.memberBankForm.get('exchangePwConfirm') + ?.value as string; + + if (!password || !passwordConfirm) { + this.showAlert('error', '비밀번호를 입력하세요.'); + this.closeChangePasswordAlert(); + return; + } + + if (password !== passwordConfirm) { + this.showAlert('error', '비밀번호가 일치하지 않습니다.'); + + this.closeChangePasswordAlert(); + return; + } + + const dialogRef = this._fuseConfirmationService.open( + this.passwordConfirmConfigForm.value + ); + + /* const dialogRef = this._matDialog.open(AddComposeComponent); */ + + dialogRef.afterClosed().subscribe((result) => { + if (result === 'confirmed') { + const req = new UpdateMemberBankAccountForExchangePasswordRequest(); + req.setExchangePassword(password); + req.setId(this.currentMember!.getId()); + + this._memberBankAccountService + .updateMemberBankAccountForExchangePassword(req) + .then((result) => { + this.showAlert('success', '비밀번호가 수정 되었습니다.'); + }) + .catch((reson) => { + this.showAlert('error', '패스워드 변경이 실패하였습니다.'); + }) + .finally(() => this.closeChangePasswordAlert()); + } + }); + } + onSelectionChangeLanguage(event: MatSelectChange) { const state = event.value; @@ -561,6 +659,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { type, message, }; + this._changeDetectorRef.markForCheck(); } private closeChangePasswordAlert(): void { diff --git a/src/app/modules/polyglot/member_bank_account/services/member_bank_account.service.ts b/src/app/modules/polyglot/member_bank_account/services/member_bank_account.service.ts index 3b77706..869be22 100644 --- a/src/app/modules/polyglot/member_bank_account/services/member_bank_account.service.ts +++ b/src/app/modules/polyglot/member_bank_account/services/member_bank_account.service.ts @@ -16,6 +16,7 @@ import { GetMemberBankAccountResponse, GetMemberBankAccountRequest, UpdateMemberBankAccountForExchangePasswordResponse, + UpdateMemberBankAccountForExchangePasswordRequest, } from 'app/modules/proto/c2se/member_bank_account_pb'; import { SUBJECT_LIST_MEMBER_BANK_ACCOUNTS, @@ -112,11 +113,11 @@ export class MemberBankAccountService { ); } - updateMemberBankAccount(): Promise { + updateMemberBankAccount( + req: UpdateMemberBankAccountRequest + ): Promise { return new Promise( (resolve, reject) => { - let req = new UpdateMemberBankAccountRequest(); - this.__natsService .request( SUBJECT_UPDATE_MEMBER_BANK_ACCOUNT, @@ -135,11 +136,11 @@ export class MemberBankAccountService { ); } - updateMemberBankAccountForExchangePassword(): Promise { + updateMemberBankAccountForExchangePassword( + req: UpdateMemberBankAccountForExchangePasswordRequest + ): Promise { return new Promise( (resolve, reject) => { - let req = new UpdateMemberBankAccountForExchangePasswordResponse(); - this.__natsService .request( SUBJECT_UPDATE_MEMBER_BANK_ACCOUNT_FOR_EXCHANGE_PASSWORD, From 3b71dd1fe3d31dcd2ec89b2229822beb00aacfdd Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Thu, 25 Aug 2022 06:30:48 +0000 Subject: [PATCH 2/2] bug fix --- .../member/user/components/view.component.ts | 30 ++++++----- .../user/resolvers/member-bank.resolver.ts | 50 +++++++++++++++++ .../member/user/resolvers/user.resolver.ts | 54 ------------------- .../modules/admin/member/user/user.routing.ts | 2 + 4 files changed, 69 insertions(+), 67 deletions(-) create mode 100644 src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts diff --git a/src/app/modules/admin/member/user/components/view.component.ts b/src/app/modules/admin/member/user/components/view.component.ts index cd535b8..d09e34f 100644 --- a/src/app/modules/admin/member/user/components/view.component.ts +++ b/src/app/modules/admin/member/user/components/view.component.ts @@ -59,6 +59,8 @@ import { UpdateMemberBankAccountRequest, } from 'app/modules/proto/c2se/member_bank_account_pb'; import { MemberBankAccountService } from 'app/modules/polyglot/member_bank_account/services/member_bank_account.service'; +import { ListBanksResponse } from 'app/modules/proto/c2se/bank_pb'; +import { ListMemberClassesResponse } from 'app/modules/proto/c2se/member_class_pb'; @Component({ selector: 'user-view', @@ -299,18 +301,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); }); - /* this._memberLevelService.listMemberLevels().then((result) => { - this.memberLevels = result - .getMemberLevelsList() - .filter((v) => !!v.getShow()); - - this.memberDefaultForm - .get('levelName') - ?.setValue(this.currentMember?.getMemberLevel()?.getName()); - this._changeDetectorRef.markForCheck(); - }); */ - - this._bankService.listBanks().then((result) => { + /* this._bankService.listBanks().then((result) => { this.memberBankForm.get('bankName')?.value; this.memberBankForm.patchValue({ @@ -323,7 +314,7 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); this.banks = result.getBanksList(); - }); + }); */ this._activatedRoute.data.subscribe((data) => { let member: GetMemberResponse.Result = data['member']; @@ -347,6 +338,19 @@ export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { data['listMemberLevels']; this.memberLevels = listMemberLevelsResult.getMemberLevelsList(); + let listMemberClassesResult: ListMemberClassesResponse.Result = + data['listMemberClasses']; + + let listbanksResult: ListBanksResponse.Result = data['listMemberBanks']; + this.banks = listbanksResult.getBanksList(); + + this.memberBankForm.patchValue({ + bankName: this.currentMember?.getBankAccount()?.getBank()?.getName(), + accountNumber: this.currentMember?.getBankAccount()?.getAccountNumber(), + accountHolder: this.currentMember?.getBankAccount()?.getName(), + description: this.currentMember?.getBankAccount()?.getMemo(), + }); + // Mark for check this._changeDetectorRef.markForCheck(); }); diff --git a/src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts b/src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts new file mode 100644 index 0000000..5ca18fe --- /dev/null +++ b/src/app/modules/admin/member/user/resolvers/member-bank.resolver.ts @@ -0,0 +1,50 @@ +import { Injectable } from '@angular/core'; +import { + ActivatedRouteSnapshot, + Resolve, + Router, + RouterStateSnapshot, +} from '@angular/router'; +import { BankService } from 'app/modules/polyglot/bank/services/bank.service'; +import { MemberClassService } from 'app/modules/polyglot/member_class/services/member_class.service'; +import { + ListBanksRequest, + ListBanksResponse, +} from 'app/modules/proto/c2se/bank_pb'; +import { + ListMemberClassesRequest, + ListMemberClassesResponse, +} from 'app/modules/proto/c2se/member_class_pb'; + +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root', +}) +export class ListMemberBanksResolver implements Resolve { + /** + * Constructor + */ + constructor(private _router: Router, private __bankService: BankService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListBanksResponse.Result { + return this.__bankService.listBanks(); + } +} diff --git a/src/app/modules/admin/member/user/resolvers/user.resolver.ts b/src/app/modules/admin/member/user/resolvers/user.resolver.ts index a61cf44..8608dfa 100644 --- a/src/app/modules/admin/member/user/resolvers/user.resolver.ts +++ b/src/app/modules/admin/member/user/resolvers/user.resolver.ts @@ -161,57 +161,3 @@ export class MemberResolver implements Resolve { return this._memberService.getMember(memberId!); } } - -export class SitesResolver implements Resolve { - /** - * Constructor - */ - constructor(private __siteService: SiteService) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Resolver - * - * @param route - * @param state - */ - resolve( - route: ActivatedRouteSnapshot, - state: RouterStateSnapshot - ): - | Observable - | Promise - | ListSitesResponse.Result { - return this.__siteService.listSites(); - } -} - -export class BanksResolver implements Resolve { - /** - * Constructor - */ - constructor(private _bankService: BankService) {} - - // ----------------------------------------------------------------------------------------------------- - // @ Public methods - // ----------------------------------------------------------------------------------------------------- - - /** - * Resolver - * - * @param route - * @param state - */ - resolve( - route: ActivatedRouteSnapshot, - state: RouterStateSnapshot - ): - | Observable - | Promise - | ListBanksResponse.Result { - return this._bankService.listBanks(); - } -} diff --git a/src/app/modules/admin/member/user/user.routing.ts b/src/app/modules/admin/member/user/user.routing.ts index ee7454c..70bb64f 100644 --- a/src/app/modules/admin/member/user/user.routing.ts +++ b/src/app/modules/admin/member/user/user.routing.ts @@ -2,6 +2,7 @@ import { Route } from '@angular/router'; import { ListComponent } from 'app/modules/admin/member/user/components/list.component'; import { ViewComponent } from 'app/modules/admin/member/user/components/view.component'; +import { ListMemberBanksResolver } from './resolvers/member-bank.resolver'; import { ListMemberClassesResolver } from './resolvers/member-class.resolver'; import { ListMemberLevelsResolver } from './resolvers/member-level.resolver'; @@ -15,6 +16,7 @@ export const userRoutes: Route[] = [ listmembers: ListMemberResolver, listMemberClasses: ListMemberClassesResolver, listMemberLevels: ListMemberLevelsResolver, + listMemberBanks: ListMemberBanksResolver, }, }, {