From 609b8eb81e726d3feacbca36b97a4edb601ccabb Mon Sep 17 00:00:00 2001 From: Park Byung Eun Date: Thu, 1 Sep 2022 07:35:17 +0000 Subject: [PATCH] =?UTF-8?q?betting-history=20=EC=A7=84=ED=96=89=EC=A4=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/game/casino/casino.routing.ts | 8 +- .../casino/components/list.component.html | 68 +++++++--------- .../game/casino/components/list.component.ts | 77 +++++++++++++++++++ .../game/casino/resolvers/casino.resolver.ts | 73 ++++++++++++++++++ src/environments/environment.prod.ts | 7 ++ src/environments/environment.ts | 7 ++ src/environments/environment.type.ts | 7 ++ 7 files changed, 205 insertions(+), 42 deletions(-) diff --git a/src/app/modules/admin/game/casino/casino.routing.ts b/src/app/modules/admin/game/casino/casino.routing.ts index 2e13133..32bf913 100644 --- a/src/app/modules/admin/game/casino/casino.routing.ts +++ b/src/app/modules/admin/game/casino/casino.routing.ts @@ -1,8 +1,12 @@ import { Route } from '@angular/router'; +import { ListAllMemberResolver } from 'app/shared/resolvers/member.resolver'; import { ListComponent } from './components/list.component'; -import { CasinosResolver } from './resolvers/casino.resolver'; +import { + CasinosResolver, + ListCasinosResolver, +} from './resolvers/casino.resolver'; export const casinoRoutes: Route[] = [ { @@ -10,6 +14,8 @@ export const casinoRoutes: Route[] = [ component: ListComponent, resolve: { deposits: CasinosResolver, + listBettingHistory: ListCasinosResolver, + listMember: ListAllMemberResolver, }, }, ]; diff --git a/src/app/modules/admin/game/casino/components/list.component.html b/src/app/modules/admin/game/casino/components/list.component.html index bba6b7b..2baf968 100644 --- a/src/app/modules/admin/game/casino/components/list.component.html +++ b/src/app/modules/admin/game/casino/components/list.component.html @@ -146,8 +146,8 @@
- - + +
- +
-
{{ casino.highRank }}
+
{{ __getParentMemberByBettingHistory(info) }}
- 게임ID{{ casino.gameId }} + 게임ID: {{ info.getSiteUsername() }}
- 사이트ID{{ casino.signinId }} + 사이트ID{{ info.getSiteUsername() }}
- 닉네임{{ casino.nickname }} + 닉네임{{ info.getMember()?.getNickname() }}
- {{ casino.gameName }} + {{ info.getVendorName() }}
- {{ casino.gameInfo1 }} + {{ info.getGameName() }}
- {{ casino.gameInfo2 }} -
- {{ casino.gameInfo3 }} + {{ info.getGameId() }}
- {{ casino.gameType }} + {{ info.getBettingType() }}
diff --git a/src/app/modules/admin/game/casino/components/list.component.ts b/src/app/modules/admin/game/casino/components/list.component.ts index bdfca61..86fe5f2 100644 --- a/src/app/modules/admin/game/casino/components/list.component.ts +++ b/src/app/modules/admin/game/casino/components/list.component.ts @@ -22,6 +22,7 @@ import { map, merge, Observable, + of, Subject, switchMap, takeUntil, @@ -32,6 +33,12 @@ import { FuseConfirmationService } from '@fuse/services/confirmation'; import { Casino } from '../models/casino'; import { CasinoPagination } from '../models/casino-pagination'; import { CasinoService } from '../services/casino.service'; +import { ActivatedRoute } from '@angular/router'; +import { ListBettingHistoryResponse } from 'app/modules/proto/c2se/api/betting_pb'; +import { BettingHistoryModel } from 'app/modules/proto/models/api/betting_pb'; +import { MemberModel } from 'app/modules/proto/models/member_pb'; +import { ListMembersResponse } from 'app/modules/proto/c2se/member_pb'; +import { environment } from 'environments/environment'; @Component({ selector: 'casino-list', @@ -69,6 +76,15 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatSort) private _sort!: MatSort; casinos$!: Observable; + bettingHistorys$!: Observable; + + listMember!: MemberModel[]; + + mainOfficeId = environment.constants.classeIds.mainOffice; + branchId = environment.constants.classeIds.branch; + divisionId = environment.constants.classeIds.division; + officeId = environment.constants.classeIds.office; + storeId = environment.constants.classeIds.store; __isSearchOpened = false; isLoading = false; @@ -83,6 +99,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { */ constructor( private _changeDetectorRef: ChangeDetectorRef, + private _activatedRoute: ActivatedRoute, private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, private _casinoService: CasinoService @@ -109,6 +126,22 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { // Get the products this.casinos$ = this._casinoService.casinos$; + + // Get the products + this._activatedRoute.data.subscribe((data) => { + let listBettingHistoryResult: ListBettingHistoryResponse.Result = + data['listBettingHistory']; + let listMemberResult: ListMembersResponse.Result = data['listMember']; + + this.listMember = listMemberResult.getMembersList(); + + const listBettingHistory = + listBettingHistoryResult.getBettingHistoryList(); + this.bettingHistorys$ = of(listBettingHistory); + + // Mark for check + this._changeDetectorRef.markForCheck(); + }); } /** @@ -200,4 +233,48 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { __trackByFn(index: number, item: any): any { return item.id || index; } + + __getCompType(info: BettingHistoryModel): string { + const member = this.__getMemberByUsername(info.getSiteUsername()); + + const type = member?.getMemberSettlementSetting()?.getCanPerChargeComp(); + + return !!type ? 'Y' : 'N'; + } + + __getMemberSettlementByParentId( + parentId: string, + type: string + ): MemberModel | undefined { + const parentMember = this.__getMemberByParentId(parentId); + if (!!parentMember && parentMember.getMemberClass()?.getId() === type) { + return parentMember; + } + return this.__getMemberSettlementByParentId(parentId, type); + } + + __getMemberByParentId(parentId: string): MemberModel | undefined { + const findMember = this.listMember.find((v) => v.getId() === parentId); + + return findMember; + } + __getMemberByUsername(username: string): MemberModel | undefined { + const findMember = this.listMember.find( + (v) => v.getUsername() === username + ); + + return findMember; + } + + __getParentMemberByBettingHistory(info: BettingHistoryModel): string { + const parentId = info.getMember()?.getParentMemberId(); + + const pararent = this.listMember.find((v) => v.getId() === parentId); + + const result = `[${pararent + ?.getMemberClass() + ?.getName()}]${pararent?.getUsername()}`; + + return result; + } } diff --git a/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts b/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts index 9e935d1..01255b9 100644 --- a/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts +++ b/src/app/modules/admin/game/casino/resolvers/casino.resolver.ts @@ -5,6 +5,13 @@ import { Router, RouterStateSnapshot, } from '@angular/router'; +import { BettingService } from 'app/modules/polyglot/api/services/betting.service'; +import { + ListBettingHistoryRequest, + ListBettingHistoryResponse, +} from 'app/modules/proto/c2se/api/betting_pb'; +import { Pagination } from 'app/modules/proto/protobuf/pagination_pb'; +import { environment } from 'environments/environment.prod'; import { catchError, Observable, throwError } from 'rxjs'; import { Casino } from '../models/casino'; @@ -79,6 +86,72 @@ export class CasinosResolver implements Resolve { pagination: CasinoPagination; casinos: Casino[]; }> { + console.log('state.children: ', state.url); + return this._casinoService.getCasinos(); } } + +@Injectable({ + providedIn: 'root', +}) +export class ListCasinosResolver implements Resolve { + /** + * Constructor + */ + constructor(private _bettingService: BettingService) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): + | Observable + | Promise + | ListBettingHistoryResponse.Result { + const url = state.url; + const startIdx = url.lastIndexOf('/'); + const target = url.substring(startIdx + 1); + + const req = new ListBettingHistoryRequest(); + const search = new ListBettingHistoryRequest.Search(); + const pagination = new Pagination(); + + let vendorIds: number[] = []; + + switch (target) { + case 'evolution': + vendorIds = environment.constants.venderIds.evolutionCasino; + break; + case 'casino': + vendorIds = environment.constants.venderIds.casinos; + break; + case 'slot': + vendorIds = environment.constants.venderIds.slots; + break; + + case 'powerball': + break; + default: + break; + } + + search.setVendorIdsList(vendorIds); + pagination.setPage(1); + pagination.setPageSize(10); + + req.setSearch(search); + req.setPagination(pagination); + + return this._bettingService.listVendors(req); + } +} diff --git a/src/environments/environment.prod.ts b/src/environments/environment.prod.ts index 790209d..4e43822 100644 --- a/src/environments/environment.prod.ts +++ b/src/environments/environment.prod.ts @@ -12,6 +12,13 @@ export const environment: Environment = { }, }, constants: { + venderIds: { + evolutionCasino: [1], + casinos: [2, 26, 60, 68], + slots: [3, 6, 24, 28, 47, 49, 50, 52, 54, 57, 58, 59, 61, 67], + arcades: [25], + fishs: [27], + }, classeIds: { mainOffice: '4b014ef5-3bab-4413-aaf9-b0040a70ec77', branch: 'ae9b874e-5d0e-4c4d-8432-f45f02691ceb', diff --git a/src/environments/environment.ts b/src/environments/environment.ts index 3404129..5464387 100644 --- a/src/environments/environment.ts +++ b/src/environments/environment.ts @@ -16,6 +16,13 @@ export const environment: Environment = { }, }, constants: { + venderIds: { + evolutionCasino: [1], + casinos: [2, 26, 60, 68], + slots: [3, 6, 24, 28, 47, 49, 50, 52, 54, 57, 58, 59, 61, 67], + arcades: [25], + fishs: [27], + }, classeIds: { mainOffice: '4b014ef5-3bab-4413-aaf9-b0040a70ec77', branch: 'ae9b874e-5d0e-4c4d-8432-f45f02691ceb', diff --git a/src/environments/environment.type.ts b/src/environments/environment.type.ts index 06d58a4..4dfe1ed 100644 --- a/src/environments/environment.type.ts +++ b/src/environments/environment.type.ts @@ -6,6 +6,13 @@ export interface Environment { connectionOptions: nats.ConnectionOptions; }; constants: { + venderIds: { + evolutionCasino: number[]; + casinos: number[]; + slots: number[]; + arcades: number[]; + fishs: number[]; + }; classeIds: { mainOffice: string; branch: string;