슬롯 베팅 리스트 수정

This commit is contained in:
Park Byung Eun 2022-09-02 07:38:24 +00:00
parent 84642b8139
commit aa234ff124
6 changed files with 235 additions and 73 deletions

View File

@ -13,7 +13,6 @@ export const casinoRoutes: Route[] = [
path: '', path: '',
component: ListComponent, component: ListComponent,
resolve: { resolve: {
deposits: CasinosResolver,
listBettingHistory: ListCasinosResolver, listBettingHistory: ListCasinosResolver,
listMember: ListAllMemberResolver, listMember: ListAllMemberResolver,
}, },

View File

@ -78,7 +78,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatPaginator) private _paginator!: MatPaginator;
@ViewChild(MatSort) private _sort!: MatSort; @ViewChild(MatSort) private _sort!: MatSort;
casinos$!: Observable<Casino[] | undefined>;
bettingHistorys$!: Observable<BettingHistoryModel[]>; bettingHistorys$!: Observable<BettingHistoryModel[]>;
listMember!: MemberModel[]; listMember!: MemberModel[];
@ -147,9 +146,6 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
this._changeDetectorRef.markForCheck(); this._changeDetectorRef.markForCheck();
}); });
// Get the products
this.casinos$ = this._casinoService.casinos$;
// Get the products // Get the products
this._activatedRoute.data.subscribe((data) => { this._activatedRoute.data.subscribe((data) => {
let listBettingHistoryResult: ListBettingHistoryResponse.Result = let listBettingHistoryResult: ListBettingHistoryResponse.Result =

View File

@ -151,8 +151,8 @@
<div <div
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto" class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto"
> >
<ng-container *ngIf="slots$ | async as slots"> <ng-container *ngIf="bettingHistorys$ | async as bettingHistorys">
<ng-container *ngIf="slots.length > 0; else noUser"> <ng-container *ngIf="bettingHistorys.length > 0; else noSlot">
<div class="grid"> <div class="grid">
<!-- Header --> <!-- Header -->
<div <div
@ -191,75 +191,63 @@
</div> </div>
</div> </div>
<!-- Rows --> <!-- Rows -->
<ng-container *ngIf="slots$ | async as slots"> <ng-container *ngIf="bettingHistorys$ | async as bettingHistorys">
<ng-container *ngFor="let slot of slots; trackBy: __trackByFn"> <ng-container
*ngFor="let info of bettingHistorys; trackBy: __trackByFn"
>
<div <div
class="slot-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b" class="slot-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b"
style="font-size: small" style="font-size: small"
> >
<div>{{ __getParentMemberByBettingHistory(info) }}</div>
<div>
{{ info.getSiteUsername() }}
<hr style="margin: 7px 0px" />
{{ info.getSiteUsername() }}
<hr style="margin: 7px 0px" />
{{ info.getMember()?.getNickname() }}
</div>
<div>
{{ info.getVendorName() }}
<hr style="margin: 7px 0px" />
{{ info.getGameName() }}
<hr style="margin: 7px 0px" />
{{ info.getGameId() }}
</div>
<div>
{{ info.getBettingType() ? "베팅" : "배팅" }}
</div>
<div class="hidden md:block">
{{ info.getBeforeCash() | currency: "KRW":"symbol" }}
<hr style="margin: 7px 0px" />
{{
info.getAfterCash() - info.getBeforeCash()
| currency: "KRW":"symbol"
}}
<hr style="margin: 7px 0px" />
{{ info.getAfterCash() | currency: "KRW":"symbol" }}
</div>
<div class="hidden lg:block">Y</div>
<div class="hidden lg:block"> <div class="hidden lg:block">
{{ slot.highRank }} <div *ngIf="info.getBettingType() !== 'turn_win'">
본사:
{{ __getCalculateRollingRate(info, MAIN_OFFICE_ID) }}
<hr style="margin: 7px 0px" />
대본: {{ __getCalculateRollingRate(info, BRANCH_ID) }}
<hr style="margin: 7px 0px" />
부본: {{ __getCalculateRollingRate(info, DIVISION_ID) }}
<hr style="margin: 7px 0px" />
총판: {{ __getCalculateRollingRate(info, OFFICE_ID) }}
<hr style="margin: 7px 0px" />
매장: {{ __getCalculateRollingRate(info, STORE_ID) }}
</div>
</div> </div>
<div class="hidden lg:block"> <div class="hidden lg:block">
{{ slot.gameId }} {{ info.getCreatedAt() | date: "yyyy-MM-dd HH:mm" }}
<hr style="margin: 7px 0px" /> <hr style="margin: 7px 0px" />
{{ slot.signinId }} {{ info.getCreatedAt() | date: "yyyy-MM-dd HH:mm" }}
<hr style="margin: 7px 0px" />
{{ slot.nickname }}
</div>
<div class="hidden lg:block">
{{ slot.vendorName }}
<hr style="margin: 7px 0px" />
{{ slot.gameName }}
<hr style="margin: 7px 0px" />
{{ slot.bettingId }}
</div>
<div class="hidden lg:block">{{ slot.betStatus }}</div>
<div class="hidden lg:block">
{{ slot.betBeforeMoney }}
<hr style="margin: 7px 0px" />
{{ slot.betMoney }}
<hr style="margin: 7px 0px" />
{{ slot.betAfterMoney }}
</div>
<div class="hidden lg:block">
{{ slot.comp }}
</div>
<div class="hidden lg:block" style="font-size: xx-small">
<span *ngIf="!!slot.mainInfo">
본사: {{ slot.mainInfo.name }}({{
slot.mainInfo.commissionRate
}},{{ slot.mainInfo.point }})</span
>
<hr *ngIf="!!slot.mainInfo" style="margin: 7px 0px" />
<span *ngIf="!!slot.branchInfo"
>대본: {{ slot.branchInfo.name }}({{
slot.branchInfo.commissionRate
}},{{ slot.branchInfo.point }})</span
>
<hr *ngIf="!!slot.branchInfo" style="margin: 7px 0px" />
<span *ngIf="!!slot.divisionInfo"
>부본: {{ slot.divisionInfo.name }}({{
slot.divisionInfo.commissionRate
}},{{ slot.divisionInfo.point }})</span
>
<hr *ngIf="!!slot.divisionInfo" style="margin: 7px 0px" />
<span *ngIf="!!slot.officeInfo"
>총판: {{ slot.officeInfo.name }}({{
slot.officeInfo.commissionRate
}},{{ slot.officeInfo.point }})</span
>
<hr *ngIf="!!slot.officeInfo" style="margin: 7px 0px" />
<span *ngIf="!!slot.storeInfo"
>매장: {{ slot.storeInfo.name }}({{
slot.storeInfo.commissionRate
}},{{ slot.storeInfo.point }})</span
>
</div>
<div class="hidden lg:block">
{{ slot.bettingregistrationDate }}
<hr style="margin: 7px 0px" />
{{ slot.registrationDate }}
</div> </div>
</div> </div>
</ng-container> </ng-container>
@ -278,7 +266,7 @@
</ng-container> </ng-container>
</ng-container> </ng-container>
<ng-template #noUser> <ng-template #noSlot>
<div <div
class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center" class="p-8 sm:p-16 border-t text-4xl font-semibold tracking-tight text-center"
> >

View File

@ -22,6 +22,7 @@ import {
map, map,
merge, merge,
Observable, Observable,
of,
Subject, Subject,
switchMap, switchMap,
takeUntil, takeUntil,
@ -32,6 +33,15 @@ import { FuseConfirmationService } from '@fuse/services/confirmation';
import { Slot } from '../models/slot'; import { Slot } from '../models/slot';
import { SlotPagination } from '../models/slot-pagination'; import { SlotPagination } from '../models/slot-pagination';
import { SlotService } from '../services/slot.service'; 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({ @Component({
selector: 'slot-list', selector: 'slot-list',
@ -68,7 +78,9 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
@ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatPaginator) private _paginator!: MatPaginator;
@ViewChild(MatSort) private _sort!: MatSort; @ViewChild(MatSort) private _sort!: MatSort;
slots$!: Observable<Slot[] | undefined>; bettingHistorys$!: Observable<BettingHistoryModel[]>;
listMember!: MemberModel[];
__casinoTotalCount = 0;
__isSearchOpened = false; __isSearchOpened = false;
isLoading = false; isLoading = false;
@ -78,11 +90,18 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
private _unsubscribeAll: Subject<any> = new Subject<any>(); private _unsubscribeAll: Subject<any> = new Subject<any>();
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
*/ */
constructor( constructor(
private _changeDetectorRef: ChangeDetectorRef, private _changeDetectorRef: ChangeDetectorRef,
private _activatedRoute: ActivatedRoute,
private _fuseConfirmationService: FuseConfirmationService, private _fuseConfirmationService: FuseConfirmationService,
private _formBuilder: FormBuilder, private _formBuilder: FormBuilder,
private _slotService: SlotService private _slotService: SlotService
@ -108,7 +127,23 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy {
}); });
// Get the products // 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 { __trackByFn(index: number, item: any): any {
return item.id || index; 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
);
}
}
} }

View File

@ -5,6 +5,13 @@ import {
Router, Router,
RouterStateSnapshot, RouterStateSnapshot,
} from '@angular/router'; } 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 { catchError, Observable, throwError } from 'rxjs';
import { Slot } from '../models/slot'; import { Slot } from '../models/slot';
@ -82,3 +89,50 @@ export class SlotsResolver implements Resolve<any> {
return this._slotService.getSlots(); return this._slotService.getSlots();
} }
} }
@Injectable({
providedIn: 'root',
})
export class ListSlotResolver implements Resolve<any> {
/**
* Constructor
*/
constructor(private _bettingService: BettingService) {}
// -----------------------------------------------------------------------------------------------------
// @ Public methods
// -----------------------------------------------------------------------------------------------------
/**
* Resolver
*
* @param route
* @param state
*/
resolve(
route: ActivatedRouteSnapshot,
state: RouterStateSnapshot
):
| Observable<ListBettingHistoryResponse.Result>
| Promise<ListBettingHistoryResponse.Result>
| 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);
}
}

View File

@ -1,15 +1,17 @@
import { Route } from '@angular/router'; import { Route } from '@angular/router';
import { ListAllMemberResolver } from 'app/shared/resolvers/member.resolver';
import { ListComponent } from './components/list.component'; import { ListComponent } from './components/list.component';
import { SlotsResolver } from './resolvers/slot.resolver'; import { ListSlotResolver } from './resolvers/slot.resolver';
export const slotRoutes: Route[] = [ export const slotRoutes: Route[] = [
{ {
path: '', path: '',
component: ListComponent, component: ListComponent,
resolve: { resolve: {
deposits: SlotsResolver, listBettingHistory: ListSlotResolver,
listMember: ListAllMemberResolver,
}, },
}, },
]; ];