betting-history 진행중

This commit is contained in:
Park Byung Eun 2022-09-01 07:35:17 +00:00
parent 9b16bf5b34
commit 609b8eb81e
7 changed files with 205 additions and 42 deletions

View File

@ -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,
},
},
];

View File

@ -146,8 +146,8 @@
<div
class="flex flex-col flex-auto sm:mb-18 overflow-hidden sm:overflow-y-auto overflow-x-auto"
>
<ng-container *ngIf="casinos$ | async as casinos">
<ng-container *ngIf="casinos.length > 0; else noCasino">
<ng-container *ngIf="bettingHistorys$ | async as bettingHistorys">
<ng-container *ngIf="bettingHistorys.length > 0; else noCasino">
<div class="grid">
<!-- Header -->
<div
@ -169,46 +169,44 @@
</div>
</div>
<!-- Rows -->
<ng-container *ngIf="casinos$ | async as casinos">
<ng-container *ngIf="bettingHistorys$ | async as bettingHistorys">
<ng-container
*ngFor="let casino of casinos; trackBy: __trackByFn"
*ngFor="let info of bettingHistorys; trackBy: __trackByFn"
>
<div
class="casino-grid grid items-center gap-4 py-3 px-6 md:px-8 border-b"
>
<div>{{ casino.highRank }}</div>
<div>{{ __getParentMemberByBettingHistory(info) }}</div>
<div>
게임ID{{ casino.gameId }}
게임ID: {{ info.getSiteUsername() }}
<hr style="margin: 7px 0px" />
사이트ID{{ casino.signinId }}
사이트ID{{ info.getSiteUsername() }}
<hr style="margin: 7px 0px" />
닉네임{{ casino.nickname }}
닉네임{{ info.getMember()?.getNickname() }}
</div>
<div>
{{ casino.gameName }}
{{ info.getVendorName() }}
<hr style="margin: 7px 0px" />
{{ casino.gameInfo1 }}
{{ info.getGameName() }}
<hr style="margin: 7px 0px" />
{{ casino.gameInfo2 }}
<hr style="margin: 7px 0px" />
{{ casino.gameInfo3 }}
{{ info.getGameId() }}
</div>
<div>
{{ casino.gameType }}
{{ info.getBettingType() }}
</div>
<div class="hidden sm:block">
당첨전{{ casino.beforeWinning }}
배팅: {{ info.getCash() }}
<hr style="margin: 7px 0px" />
당첨{{ casino.winning }}
당첨: {{ info.getAfterCash() - info.getBeforeCash() }}
<hr style="margin: 7px 0px" />
당첨후{{ casino.afterWinning }}
손익: {{ info.getAfterCash() - info.getBeforeCash() }}
</div>
<div class="hidden md:block">
{{ casino.bettingInfo1 }}
배팅전: {{ info.getBeforeCash() }}
<hr style="margin: 7px 0px" />
{{ casino.bettingInfo2 }}
배팅후: {{ info.getAfterCash() - info.getBeforeCash() }}
<hr style="margin: 7px 0px" />
{{ casino.bettingInfo3 }}
최종금액: {{ info.getAfterCash() }}
</div>
<div class="hidden md:block">
<button
@ -220,37 +218,25 @@
</button>
</div>
<div class="hidden md:block">
{{ casino.comp }}
{{ __getCompType(info) }}
</div>
<div class="hidden lg:block">
본사{{ casino.mainofficeName }}({{
casino.mainofficePercent
}}%&nbsp;:&nbsp;{{ casino.mainofficePoint }}P)
본사100P
<hr style="margin: 7px 0px" />
대본{{ casino.branchName }}({{
casino.branchPercent
}}%&nbsp;:&nbsp;{{ casino.branchPoint }}P)
대본100P
<hr style="margin: 7px 0px" />
부본{{ casino.divisionName }}({{
casino.divisionPercent
}}%&nbsp;:&nbsp;{{ casino.divisionPoint }}P)
부본100P
<hr style="margin: 7px 0px" />
총판{{ casino.officeName }}({{
casino.officePercent
}}%&nbsp;:&nbsp;{{ casino.officePoint }}P)
총판120P
<hr style="margin: 7px 0px" />
매장{{ casino.storeName }}({{
casino.storePercent
}}%&nbsp;:&nbsp;{{ casino.storePoint }}P)
매장100P
<hr style="margin: 7px 0px" />
회원{{ casino.memberName }}({{
casino.memberPercent
}}%&nbsp;:&nbsp;{{ casino.memberPoint }}P)
회원100p
</div>
<div class="hidden lg:block">
{{ casino.bettingTime }}
{{ info.getCreatedAt() | date: "yyyy-MM-dd HH:mm" }}
<hr style="margin: 7px 0px" />
{{ casino.registrationDate }}
{{ info.getCreatedAt() | date: "yyyy-MM-dd HH:mm" }}
</div>
</div>
</ng-container>

View File

@ -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<Casino[] | undefined>;
bettingHistorys$!: Observable<BettingHistoryModel[]>;
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;
}
}

View File

@ -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<any> {
pagination: CasinoPagination;
casinos: Casino[];
}> {
console.log('state.children: ', state.url);
return this._casinoService.getCasinos();
}
}
@Injectable({
providedIn: 'root',
})
export class ListCasinosResolver 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[] = [];
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);
}
}

View File

@ -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',

View File

@ -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',

View File

@ -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;