diff --git a/src/app/modules/admin/game/casino/casino.routing.ts b/src/app/modules/admin/game/casino/casino.routing.ts index 32bf913..48c18c6 100644 --- a/src/app/modules/admin/game/casino/casino.routing.ts +++ b/src/app/modules/admin/game/casino/casino.routing.ts @@ -13,7 +13,6 @@ export const casinoRoutes: Route[] = [ path: '', component: ListComponent, resolve: { - deposits: CasinosResolver, listBettingHistory: ListCasinosResolver, listMember: ListAllMemberResolver, }, 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 57ee8ce..b625a2b 100644 --- a/src/app/modules/admin/game/casino/components/list.component.ts +++ b/src/app/modules/admin/game/casino/components/list.component.ts @@ -78,7 +78,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatSort) private _sort!: MatSort; - casinos$!: Observable; bettingHistorys$!: Observable; listMember!: MemberModel[]; @@ -147,9 +146,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { this._changeDetectorRef.markForCheck(); }); - // Get the products - this.casinos$ = this._casinoService.casinos$; - // Get the products this._activatedRoute.data.subscribe((data) => { let listBettingHistoryResult: ListBettingHistoryResponse.Result = diff --git a/src/app/modules/admin/game/slot/components/list.component.html b/src/app/modules/admin/game/slot/components/list.component.html index a07b99c..d14d603 100644 --- a/src/app/modules/admin/game/slot/components/list.component.html +++ b/src/app/modules/admin/game/slot/components/list.component.html @@ -151,8 +151,8 @@
- - + +
- - + +
+
{{ __getParentMemberByBettingHistory(info) }}
+
+ {{ info.getSiteUsername() }} +
+ {{ info.getSiteUsername() }} +
+ {{ info.getMember()?.getNickname() }} +
+
+ {{ info.getVendorName() }} +
+ {{ info.getGameName() }} +
+ {{ info.getGameId() }} +
+
+ {{ info.getBettingType() ? "베팅" : "배팅" }} +
+ + - - - - - -
@@ -278,7 +266,7 @@
- +
diff --git a/src/app/modules/admin/game/slot/components/list.component.ts b/src/app/modules/admin/game/slot/components/list.component.ts index fb85c2a..39bb4c2 100644 --- a/src/app/modules/admin/game/slot/components/list.component.ts +++ b/src/app/modules/admin/game/slot/components/list.component.ts @@ -22,6 +22,7 @@ import { map, merge, Observable, + of, Subject, switchMap, takeUntil, @@ -32,6 +33,15 @@ import { FuseConfirmationService } from '@fuse/services/confirmation'; import { Slot } from '../models/slot'; import { SlotPagination } from '../models/slot-pagination'; import { SlotService } from '../services/slot.service'; +import { ActivatedRoute } from '@angular/router'; +import { ListBettingHistoryResponse } from 'app/modules/proto/c2se/api/betting_pb'; +import { ListMembersResponse } from 'app/modules/proto/c2se/member_pb'; +import { + MemberModel, + ParentMemberModel, +} from 'app/modules/proto/models/member_pb'; +import { BettingHistoryModel } from 'app/modules/proto/models/api/betting_pb'; +import { environment } from 'environments/environment'; @Component({ selector: 'slot-list', @@ -68,7 +78,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatSort) private _sort!: MatSort; - slots$!: Observable; + bettingHistorys$!: Observable; + listMember!: MemberModel[]; + __casinoTotalCount = 0; __isSearchOpened = false; isLoading = false; @@ -78,11 +90,18 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { private _unsubscribeAll: Subject = new Subject(); + MAIN_OFFICE_ID = environment.constants.classeIds.mainOffice; + BRANCH_ID = environment.constants.classeIds.branch; + DIVISION_ID = environment.constants.classeIds.division; + OFFICE_ID = environment.constants.classeIds.office; + STORE_ID = environment.constants.classeIds.store; + /** * Constructor */ constructor( private _changeDetectorRef: ChangeDetectorRef, + private _activatedRoute: ActivatedRoute, private _fuseConfirmationService: FuseConfirmationService, private _formBuilder: FormBuilder, private _slotService: SlotService @@ -108,7 +127,23 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { }); // Get the products - this.slots$ = this._slotService.slots$; + 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); + + this.__casinoTotalCount = listBettingHistoryResult.getTotalCount(); + + // Mark for check + this._changeDetectorRef.markForCheck(); + }); } /** @@ -200,4 +235,92 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { __trackByFn(index: number, item: any): any { return item.id || index; } + + __getParentMemberByBettingHistory(info: BettingHistoryModel): string { + const parent = info.getMember()?.getParentMember(); + + const pararent = this.listMember.find((v) => v.getId() === parent?.getId()); + + const result = `[${pararent + ?.getMemberClass() + ?.getName()}]${pararent?.getUsername()}`; + + return result; + } + + __getCalculateRollingRate( + info: BettingHistoryModel, + classId: string + ): string { + let result: string = ''; + + if (info.getBettingType() === 'turn_win') { + return result; + } + + const parentClassId = info + .getMember() + ?.getParentMember() + ?.getMemberClass() + ?.getId(); + const gameCategoryeType = info.getGameCategory(); + const gameType = info.getGameType().toLocaleLowerCase(); + const isBaccarat = gameType.includes('baccarat'); + const isRoulette = gameType.includes('isRoulette'); + + let targetMember: MemberModel | ParentMemberModel | undefined; + + let rate = 0; + + if (classId === parentClassId) { + targetMember = info.getMember()?.getParentMember(); + } else { + targetMember = this.__getMemberByParentMemberAndClassId( + info.getMember()?.getParentMember(), + classId + ); + } + + // casino & baccarat + // casino & craps + // casino & roulette + // casino & instantroulette + + if (gameCategoryeType === 'slot') { + rate = targetMember?.getMemberSettlementSetting()?.getRateSlot() || 0; + } else { + rate = 0; + } + + const betCash = info.getCash(); + const point = betCash * (rate / 100); + + result = `${targetMember?.getUsername()}(${rate}% ${point}P)`; + + return result; + } + + __getMemberByParentMemberAndClassId( + parentMember: ParentMemberModel | undefined, + classId: string + ): ParentMemberModel | undefined { + if (!parentMember) { + return; + } + + const pp = this.listMember.find((v) => v.getId() === parentMember.getId()); + + if ( + !!pp && + !!pp.getParentMember()?.getMemberClass() && + pp.getParentMember()?.getMemberClass()?.getId() === classId + ) { + return pp.getParentMember(); + } else { + return this.__getMemberByParentMemberAndClassId( + pp?.getParentMember(), + classId + ); + } + } } diff --git a/src/app/modules/admin/game/slot/resolvers/slot.resolver.ts b/src/app/modules/admin/game/slot/resolvers/slot.resolver.ts index a88f4c4..736ecb1 100644 --- a/src/app/modules/admin/game/slot/resolvers/slot.resolver.ts +++ b/src/app/modules/admin/game/slot/resolvers/slot.resolver.ts @@ -5,6 +5,13 @@ import { Router, RouterStateSnapshot, } from '@angular/router'; +import { BettingService } from 'app/modules/polyglot/api/services/betting.service'; +import { + ListBettingHistoryResponse, + ListBettingHistoryRequest, +} from 'app/modules/proto/c2se/api/betting_pb'; +import { Pagination } from 'app/modules/proto/protobuf/pagination_pb'; +import { environment } from 'environments/environment'; import { catchError, Observable, throwError } from 'rxjs'; import { Slot } from '../models/slot'; @@ -82,3 +89,50 @@ export class SlotsResolver implements Resolve { return this._slotService.getSlots(); } } + +@Injectable({ + providedIn: 'root', +}) +export class ListSlotResolver 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[] = environment.constants.venderIds.slots; + + search.setVendorIdsList(vendorIds); + pagination.setPage(1); + pagination.setPageSize(10); + + req.setSearch(search); + req.setPagination(pagination); + + return this._bettingService.listVendors(req); + } +} diff --git a/src/app/modules/admin/game/slot/slot.routing.ts b/src/app/modules/admin/game/slot/slot.routing.ts index 6643300..85d80dd 100644 --- a/src/app/modules/admin/game/slot/slot.routing.ts +++ b/src/app/modules/admin/game/slot/slot.routing.ts @@ -1,15 +1,17 @@ import { Route } from '@angular/router'; +import { ListAllMemberResolver } from 'app/shared/resolvers/member.resolver'; import { ListComponent } from './components/list.component'; -import { SlotsResolver } from './resolvers/slot.resolver'; +import { ListSlotResolver } from './resolvers/slot.resolver'; export const slotRoutes: Route[] = [ { path: '', component: ListComponent, resolve: { - deposits: SlotsResolver, + listBettingHistory: ListSlotResolver, + listMember: ListAllMemberResolver, }, }, ];