From 9baf91c5a2f60d3e786c5a2099e65150a007c424 Mon Sep 17 00:00:00 2001 From: JUNG YI DAM Date: Thu, 4 Aug 2022 05:52:52 +0000 Subject: [PATCH] =?UTF-8?q?=EC=A2=85=EB=AA=A9=EB=B3=84=EB=A7=A4=EC=B6=9C?= =?UTF-8?q?=ED=86=B5=EA=B3=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mock-api/apps/report/statistics/api.ts | 127 +++++++++--- .../mock-api/apps/report/statistics/data.ts | 107 +++++++++- .../statistics/components/list.component.html | 189 ++++++++---------- .../statistics/components/list.component.ts | 18 +- .../statistics/components/view.component.html | 4 + .../statistics/components/view.component.ts | 183 +++++++++++++++++ .../statistics/models/casino-statistics.ts | 32 +++ .../statistics/models/powerball-statistics.ts | 32 +++ .../statistics/models/slot-statistics.ts | 32 +++ .../report/statistics/models/statistics.ts | 1 + .../resolvers/statistics.resolver.ts | 147 +++++++++++++- .../statistics/services/statistics.service.ts | 153 +++++++++++--- .../report/statistics/statistics.routing.ts | 4 +- 13 files changed, 851 insertions(+), 178 deletions(-) create mode 100644 src/app/modules/admin/report/statistics/components/view.component.html create mode 100644 src/app/modules/admin/report/statistics/components/view.component.ts create mode 100644 src/app/modules/admin/report/statistics/models/casino-statistics.ts create mode 100644 src/app/modules/admin/report/statistics/models/powerball-statistics.ts create mode 100644 src/app/modules/admin/report/statistics/models/slot-statistics.ts diff --git a/src/app/mock-api/apps/report/statistics/api.ts b/src/app/mock-api/apps/report/statistics/api.ts index 69b7bee..ad55288 100644 --- a/src/app/mock-api/apps/report/statistics/api.ts +++ b/src/app/mock-api/apps/report/statistics/api.ts @@ -1,13 +1,19 @@ import { Injectable } from '@angular/core'; import { assign, cloneDeep } from 'lodash-es'; import { FuseMockApiService, FuseMockApiUtils } from '@fuse/lib/mock-api'; -import { statisticss as statisticssData } from './data'; +import { statistics as statisticsData } from './data'; +import { casinoStatistics as casinoStatisticsData } from './data'; +import { slotStatistics as slotStatisticsData } from './data'; +import { powerballStatistics as powerballStatisticsData } from './data'; @Injectable({ providedIn: 'root', }) export class ReportStatisticsMockApi { - private _statisticss: any[] = statisticssData; + private _statistics: any[] = statisticsData; + private _casinoStatistics: any[] = casinoStatisticsData; + private _slotStatistics: any[] = slotStatisticsData; + private _powerballStatistics: any[] = powerballStatisticsData; /** * Constructor @@ -26,24 +32,28 @@ export class ReportStatisticsMockApi { */ registerHandlers(): void { // ----------------------------------------------------------------------------------------------------- - // @ Statisticss - GET + // @ Statistics - GET // ----------------------------------------------------------------------------------------------------- this._fuseMockApiService - .onGet('api/apps/report/statistics/statisticss', 300) + .onGet('api/apps/report/statistics', 300) .reply(({ request }) => { // Get available queries const search = request.params.get('search'); - const sort = request.params.get('sort') || 'name'; + const sort = request.params.get('sort') || 'casinoUse'; const order = request.params.get('order') || 'asc'; const page = parseInt(request.params.get('page') ?? '1', 10); const size = parseInt(request.params.get('size') ?? '10', 10); - // Clone the statisticss - let statisticss: any[] | null = cloneDeep(this._statisticss); + // Clone the statistics + let statistics: any[] | null = cloneDeep(this._statistics); - // Sort the statisticss - if (sort === 'sku' || sort === 'name' || sort === 'active') { - statisticss.sort((a, b) => { + // Sort the statistics + if ( + sort === 'casinoUse' || + sort === 'slotUse' || + sort === 'powerballUse' + ) { + statistics.sort((a, b) => { const fieldA = a[sort].toString().toUpperCase(); const fieldB = b[sort].toString().toUpperCase(); return order === 'asc' @@ -51,15 +61,15 @@ export class ReportStatisticsMockApi { : fieldB.localeCompare(fieldA); }); } else { - statisticss.sort((a, b) => + statistics.sort((a, b) => order === 'asc' ? a[sort] - b[sort] : b[sort] - a[sort] ); } // If search exists... if (search) { - // Filter the statisticss - statisticss = statisticss.filter( + // Filter the statistics + statistics = statistics.filter( (contact: any) => contact.name && contact.name.toLowerCase().includes(search.toLowerCase()) @@ -67,32 +77,32 @@ export class ReportStatisticsMockApi { } // Paginate - Start - const statisticssLength = statisticss.length; + const statisticsLength = statistics.length; // Calculate pagination details const begin = page * size; - const end = Math.min(size * (page + 1), statisticssLength); - const lastPage = Math.max(Math.ceil(statisticssLength / size), 1); + const end = Math.min(size * (page + 1), statisticsLength); + const lastPage = Math.max(Math.ceil(statisticsLength / size), 1); // Prepare the pagination object let pagination = {}; // If the requested page number is bigger than // the last possible page number, return null for - // statisticss but also send the last possible page so + // statistics but also send the last possible page so // the app can navigate to there if (page > lastPage) { - statisticss = null; + statistics = null; pagination = { lastPage, }; } else { // Paginate the results by size - statisticss = statisticss.slice(begin, end); + statistics = statistics.slice(begin, end); // Prepare the pagination mock-api pagination = { - length: statisticssLength, + length: statisticsLength, size: size, page: page, lastPage: lastPage, @@ -105,7 +115,7 @@ export class ReportStatisticsMockApi { return [ 200, { - statisticss, + statistics, pagination, }, ]; @@ -120,16 +130,73 @@ export class ReportStatisticsMockApi { // Get the id from the params const id = request.params.get('id'); - // Clone the statisticss - const statisticss = cloneDeep(this._statisticss); + // Clone the statistics + const statistics = cloneDeep(this._statistics); // Find the statistics - const statistics = statisticss.find((item: any) => item.id === id); + statistics.find((item: any) => item.id === id); // Return the response return [200, statistics]; }); + // ----------------------------------------------------------------------------------------------------- + // @ CasinoStatistics - GET + // ----------------------------------------------------------------------------------------------------- + this._fuseMockApiService + .onGet('api/apps/report/statistics/casino-statistics') + .reply(({ request }) => { + // Get the type from the params + const id = request.params.get('type'); + + // Clone the statistics + const casinoStatistics = cloneDeep(this._statistics); + + // Find the statistics + casinoStatistics.find((item: any) => item.type === id); + + // Return the response + return [200, casinoStatistics]; + }); + + // ----------------------------------------------------------------------------------------------------- + // @ SlotStatistics - GET + // ----------------------------------------------------------------------------------------------------- + this._fuseMockApiService + .onGet('api/apps/report/statistics/slot-statistics') + .reply(({ request }) => { + // Get the type from the params + const id = request.params.get('type'); + + // Clone the statistics + const slotStatistics = cloneDeep(this._statistics); + + // Find the statistics + slotStatistics.find((item: any) => item.type === id); + + // Return the response + return [200, slotStatistics]; + }); + + // ----------------------------------------------------------------------------------------------------- + // @ PowerballStatistics - GET + // ----------------------------------------------------------------------------------------------------- + this._fuseMockApiService + .onGet('api/apps/report/statistics/powerball-statistics') + .reply(({ request }) => { + // Get the type from the params + const id = request.params.get('type'); + + // Clone the statistics + const powerballStatistics = cloneDeep(this._statistics); + + // Find the statistics + powerballStatistics.find((item: any) => item.type === id); + + // Return the response + return [200, powerballStatistics]; + }); + // ----------------------------------------------------------------------------------------------------- // @ Statistics - POST // ----------------------------------------------------------------------------------------------------- @@ -160,7 +227,7 @@ export class ReportStatisticsMockApi { }; // Unshift the new statistics - this._statisticss.unshift(newStatistics); + this._statistics.unshift(newStatistics); // Return the response return [200, newStatistics]; @@ -180,13 +247,13 @@ export class ReportStatisticsMockApi { let updatedStatistics = null; // Find the statistics and update it - this._statisticss.forEach((item, index, statisticss) => { + this._statistics.forEach((item, index, statistics) => { if (item.id === id) { // Update the statistics - statisticss[index] = assign({}, statisticss[index], statistics); + statistics[index] = assign({}, statistics[index], statistics); // Store the updated Statistics - updatedStatistics = statisticss[index]; + updatedStatistics = statistics[index]; } }); @@ -204,9 +271,9 @@ export class ReportStatisticsMockApi { const id = request.params.get('id'); // Find the statistics and delete it - this._statisticss.forEach((item, index) => { + this._statistics.forEach((item, index) => { if (item.id === id) { - this._statisticss.splice(index, 1); + this._statistics.splice(index, 1); } }); diff --git a/src/app/mock-api/apps/report/statistics/data.ts b/src/app/mock-api/apps/report/statistics/data.ts index ab7f328..f7c7563 100644 --- a/src/app/mock-api/apps/report/statistics/data.ts +++ b/src/app/mock-api/apps/report/statistics/data.ts @@ -1,6 +1,111 @@ /* eslint-disable */ -export const statisticss = [ +export const statistics = [ + { + id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c', + gameName: '라이브카지노', + casinoUse: 2, + casinoBetting: 1183000, + casinoCancel: 10000, + casinoAvailable: 1140000, + casinoWinning: 979050, + casinoWinLoss: 193950, + casinoCommission: 14810, + casinoBetWinCalculate: 179140, + slotUse: 2, + slotBetting: 225000, + slotCancel: 0, + slotAvailable: 225000, + slotWinning: 114280, + slotWinLoss: 110720, + slotTotalCommission: 11250, + slotBetWinCalculate: 99470, + powerballUse: 0, + powerballBetting: 0, + powerballWinning: 0, + powerballWinLoss: 0, + powerballCommission: 0, + powerballBetWinCalculate: 0, + totalUse: 4, + totalAvailable: 1365000, + totalBetting: 1408000, + totalCancel: 10000, + totalWinLoss: 304670, + totalCommission: 26060, + totalBetWinCalculate: 278610, + }, +]; +export const casinoStatistics = [ + { + id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c', + gameName: '슬롯', + casinoUse: 2, + casinoBetting: 1183000, + casinoCancel: 10000, + casinoAvailable: 1140000, + casinoWinning: 979050, + casinoWinLoss: 193950, + casinoCommission: 14810, + casinoBetWinCalculate: 179140, + slotUse: 2, + slotBetting: 225000, + slotCancel: 0, + slotAvailable: 225000, + slotWinning: 114280, + slotWinLoss: 110720, + slotTotalCommission: 11250, + slotBetWinCalculate: 99470, + powerballUse: 0, + powerballBetting: 0, + powerballWinning: 0, + powerballWinLoss: 0, + powerballCommission: 0, + powerballBetWinCalculate: 0, + totalUse: 4, + totalAvailable: 1365000, + totalBetting: 1408000, + totalCancel: 10000, + totalWinLoss: 304670, + totalCommission: 26060, + totalBetWinCalculate: 278610, + }, +]; +export const slotStatistics = [ + { + id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c', + gameName: '파워볼', + casinoUse: 2, + casinoBetting: 1183000, + casinoCancel: 10000, + casinoAvailable: 1140000, + casinoWinning: 979050, + casinoWinLoss: 193950, + casinoCommission: 14810, + casinoBetWinCalculate: 179140, + slotUse: 2, + slotBetting: 225000, + slotCancel: 0, + slotAvailable: 225000, + slotWinning: 114280, + slotWinLoss: 110720, + slotTotalCommission: 11250, + slotBetWinCalculate: 99470, + powerballUse: 0, + powerballBetting: 0, + powerballWinning: 0, + powerballWinLoss: 0, + powerballCommission: 0, + powerballBetWinCalculate: 0, + totalUse: 4, + totalAvailable: 1365000, + totalBetting: 1408000, + totalCancel: 10000, + totalWinLoss: 304670, + totalCommission: 26060, + totalBetWinCalculate: 278610, + }, +]; +export const powerballStatistics = [ { id: '7eb7c859-1347-4317-96b6-9476a7e2ba3c', casinoUse: 2, diff --git a/src/app/modules/admin/report/statistics/components/list.component.html b/src/app/modules/admin/report/statistics/components/list.component.html index c61ef9e..36eff38 100644 --- a/src/app/modules/admin/report/statistics/components/list.component.html +++ b/src/app/modules/admin/report/statistics/components/list.component.html @@ -24,22 +24,8 @@ *ngIf="__isSearchOpened" class="relative flex flex-col sm:flex-row flex-0 sm:items-center sm:justify-between py-4 px-6 md:px-8 border-b" > - -
- - - -
-
+ -
+ + +
+ + +
+ +
+ +
+
+ +
+
+
@@ -82,102 +97,70 @@
- +
-
요율
- - +
구분
+
이용회원
+
유효배팅
+
배팅금액
+ + + + +
- - +
-
-
요율
- - +
{{ statistics.gameName }}
+
{{ statistics.casinoUse }}명
+
{{ statistics.casinoAvailable }}원
+
{{ statistics.casinoBetting }}원
+ - + + + + + +
{{ statistics.gameName }}
+
{{ statistics.casinoUse }}명
+
{{ statistics.casinoAvailable }}원
+
{{ statistics.casinoBetting }}원
+ + + + + +
diff --git a/src/app/modules/admin/report/statistics/components/list.component.ts b/src/app/modules/admin/report/statistics/components/list.component.ts index dac93d0..a5f2a32 100644 --- a/src/app/modules/admin/report/statistics/components/list.component.ts +++ b/src/app/modules/admin/report/statistics/components/list.component.ts @@ -42,18 +42,22 @@ import { Router } from '@angular/router'; /* language=SCSS */ ` .inventory-grid { - grid-template-columns: 60px auto 40px; + /* 구분 이용 유효 배팅 당첨 취소 */ + grid-template-columns: 100px 100px auto 100px 100px 100px; @screen sm { - grid-template-columns: 60px 60px 60px 60px 60px 60px auto 60px; + /* 구분 이용 유효 배팅 당첨 취소 윈로스 수수료 뱃윈정산 */ + grid-template-columns: 100px 100px auto 100px 100px 100px 100px 100px 100px; } @screen md { - grid-template-columns: 60px 60px 60px 60px 60px 60px auto 60px 60px; + /* 구분 이용 유효 배팅 당첨 취소 윈로스 수수료 뱃윈정산 */ + grid-template-columns: 100px 100px auto 100px 100px 100px 100px 100px 100px; } @screen lg { - grid-template-columns: 60px 70px 70px 70px 70px 100px 60px 60px auto 60px 60px 60px 60px; + /* 구분 이용 유효 배팅 당첨 취소 윈로스 수수료 뱃윈정산 */ + grid-template-columns: 100px 100px auto 100px 100px 100px 100px 100px 100px; } } `, @@ -66,7 +70,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { @ViewChild(MatPaginator) private _paginator!: MatPaginator; @ViewChild(MatSort) private _sort!: MatSort; - statisticss$!: Observable; + statistics$!: Observable; users$!: Observable; __isSearchOpened = false; @@ -108,7 +112,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { }); // Get the products - this.statisticss$ = this._statisticsService.statisticss$; + this.statistics$ = this._statisticsService.statistics$; } /** @@ -139,7 +143,7 @@ export class ListComponent implements OnInit, AfterViewInit, OnDestroy { .pipe( switchMap(() => { this.isLoading = true; - return this._statisticsService.getStatisticss( + return this._statisticsService.getStatistics( this._paginator.pageIndex, this._paginator.pageSize, this._sort.active, diff --git a/src/app/modules/admin/report/statistics/components/view.component.html b/src/app/modules/admin/report/statistics/components/view.component.html new file mode 100644 index 0000000..e1ea46a --- /dev/null +++ b/src/app/modules/admin/report/statistics/components/view.component.html @@ -0,0 +1,4 @@ + +
+ 종목별매출통계 상세page +
diff --git a/src/app/modules/admin/report/statistics/components/view.component.ts b/src/app/modules/admin/report/statistics/components/view.component.ts new file mode 100644 index 0000000..82c933b --- /dev/null +++ b/src/app/modules/admin/report/statistics/components/view.component.ts @@ -0,0 +1,183 @@ +import { + AfterViewInit, + ChangeDetectionStrategy, + ChangeDetectorRef, + Component, + OnDestroy, + OnInit, + ViewChild, + ViewEncapsulation, +} from '@angular/core'; +import { + FormBuilder, + FormControl, + FormGroup, + Validators, +} from '@angular/forms'; +import { MatCheckboxChange } from '@angular/material/checkbox'; +import { MatPaginator } from '@angular/material/paginator'; +import { MatSort } from '@angular/material/sort'; +import { + debounceTime, + map, + merge, + Observable, + Subject, + switchMap, + takeUntil, +} from 'rxjs'; +import { fuseAnimations } from '@fuse/animations'; +import { FuseConfirmationService } from '@fuse/services/confirmation'; + +import { User } from 'app/modules/admin/member/user/models/user'; +import { UserService } from 'app/modules/admin/member/user/services/user.service'; + +@Component({ + selector: 'customer-view', + templateUrl: './view.component.html', + styles: [ + /* language=SCSS */ + ` + .inventory-grid { + grid-template-columns: 48px auto 40px; + + @screen sm { + grid-template-columns: 48px auto 112px 72px; + } + + @screen md { + grid-template-columns: 48px 112px auto 112px 72px; + } + + @screen lg { + grid-template-columns: 48px 112px auto 112px 96px 96px 72px; + } + } + `, + ], + encapsulation: ViewEncapsulation.None, + changeDetection: ChangeDetectionStrategy.OnPush, + animations: fuseAnimations, +}) +export class ViewComponent implements OnInit, AfterViewInit, OnDestroy { + @ViewChild(MatPaginator) private _paginator!: MatPaginator; + @ViewChild(MatSort) private _sort!: MatSort; + + isLoading = false; + searchInputControl = new FormControl(); + selectedProductForm!: FormGroup; + selectedUser?: User; + + private _unsubscribeAll: Subject = new Subject(); + + /** + * Constructor + */ + constructor( + private _changeDetectorRef: ChangeDetectorRef, + private _fuseConfirmationService: FuseConfirmationService, + private _formBuilder: FormBuilder, + private _userService: UserService + ) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Lifecycle hooks + // ----------------------------------------------------------------------------------------------------- + + /** + * On init + */ + ngOnInit(): void { + this.selectedProductForm = this._formBuilder.group({ + id: [''], + signinId: [{ value: '', disabled: true }], + signinPw: [{ value: '' }], + exchangePw: [''], + description: [''], + tags: [[]], + nickname: [{ value: '', disabled: true }], + ownCash: [''], + phoneNumber: [''], + level: [''], + status: [''], + isExcahngeMoney: [''], + bankname: [''], + accountNumber: [''], + accountHolder: [''], + comp: [''], + coupon: [''], + recommender: [{ value: '', disabled: true }], + changeSite: [''], + recommendCount: [''], + hodingGameMoney: [{ value: '0', disabled: true }], + memo: [''], + bacaraRate: [], + rulletRate: [], + dragonRate: [], + etcRate: [], + slotRate: [], + casinoRusingRate: [], + slotRusingRate: [], + }); + + // Get the User + this._userService.user$ + .pipe(takeUntil(this._unsubscribeAll)) + .subscribe((user: User | undefined) => { + if (!user) { + return; + } + this.selectedUser = user; + + this.selectedProductForm.patchValue(user); + // Mark for check + this._changeDetectorRef.markForCheck(); + }); + + /* this.user$ = this._userService.user$; */ + } + + /** + * After view init + */ + ngAfterViewInit(): void {} + + /** + * On destroy + */ + ngOnDestroy(): void { + // Unsubscribe from all subscriptions + this._unsubscribeAll.next(null); + this._unsubscribeAll.complete(); + } + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + // ----------------------------------------------------------------------------------------------------- + // @ Private methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Create product + */ + __createProduct(): void {} + + /** + * Toggle product details + * + * @param productId + */ + __toggleDetails(productId: string): void {} + + /** + * Track by function for ngFor loops + * + * @param index + * @param item + */ + __trackByFn(index: number, item: any): any { + return item.id || index; + } +} diff --git a/src/app/modules/admin/report/statistics/models/casino-statistics.ts b/src/app/modules/admin/report/statistics/models/casino-statistics.ts new file mode 100644 index 0000000..ddacf5e --- /dev/null +++ b/src/app/modules/admin/report/statistics/models/casino-statistics.ts @@ -0,0 +1,32 @@ +export interface CasinoStatistics { + id: string; + casinoUse?: number; + slotUse?: number; + powerballUse?: number; + casinoBetting?: number; // 카지노배팅 + casinoCancel?: number; // 카지노취소 + casinoAvailable?: number; // 카지노유효 + casinoWinning?: number; // 카지노당첨 + casinoWinLoss?: number; // 카지노윈로스(A) + casinoCommission?: number; // 카지노수수료(B) + casinoBetWinCalculate?: number; // 카지노벳윈정산 (A-B) + slotBetting?: number; // 슬롯배팅 + slotCancel?: number; // 슬롯취소 + slotAvailable?: number; // 슬롯유효 + slotWinning?: number; // 슬롯당첨 + slotWinLoss?: number; // 슬롯윈로스(D) + slotTotalCommission?: number; // 슬롯전체수수료(E) + slotBetWinCalculate?: number; // 슬롯벳윈정산(D-E) + powerballBetting?: number; // 파워볼배팅 + powerballWinning?: number; // 파워볼당첨 + powerballWinLoss?: number; // 파워볼윈로스(H) + powerballCommission?: number; // 파워볼수수료(I) + powerballBetWinCalculate?: number; // 파워볼벳윈정산(H-I) + totalUse?: number; // 총이용회원 + totalAvailable?: number; // 총유효배팅 + totalBetting?: number; // 총배팅 + totalCancel?: number; // 총취소 + totalWinLoss?: number; // 총윈로스 + totalCommission?: number; // 총수수료 + totalBetWinCalculate?: number; // 총벳윈정산 +} diff --git a/src/app/modules/admin/report/statistics/models/powerball-statistics.ts b/src/app/modules/admin/report/statistics/models/powerball-statistics.ts new file mode 100644 index 0000000..daee810 --- /dev/null +++ b/src/app/modules/admin/report/statistics/models/powerball-statistics.ts @@ -0,0 +1,32 @@ +export interface PowerballStatistics { + id: string; + casinoUse?: number; + slotUse?: number; + powerballUse?: number; + casinoBetting?: number; // 카지노배팅 + casinoCancel?: number; // 카지노취소 + casinoAvailable?: number; // 카지노유효 + casinoWinning?: number; // 카지노당첨 + casinoWinLoss?: number; // 카지노윈로스(A) + casinoCommission?: number; // 카지노수수료(B) + casinoBetWinCalculate?: number; // 카지노벳윈정산 (A-B) + slotBetting?: number; // 슬롯배팅 + slotCancel?: number; // 슬롯취소 + slotAvailable?: number; // 슬롯유효 + slotWinning?: number; // 슬롯당첨 + slotWinLoss?: number; // 슬롯윈로스(D) + slotTotalCommission?: number; // 슬롯전체수수료(E) + slotBetWinCalculate?: number; // 슬롯벳윈정산(D-E) + powerballBetting?: number; // 파워볼배팅 + powerballWinning?: number; // 파워볼당첨 + powerballWinLoss?: number; // 파워볼윈로스(H) + powerballCommission?: number; // 파워볼수수료(I) + powerballBetWinCalculate?: number; // 파워볼벳윈정산(H-I) + totalUse?: number; // 총이용회원 + totalAvailable?: number; // 총유효배팅 + totalBetting?: number; // 총배팅 + totalCancel?: number; // 총취소 + totalWinLoss?: number; // 총윈로스 + totalCommission?: number; // 총수수료 + totalBetWinCalculate?: number; // 총벳윈정산 +} diff --git a/src/app/modules/admin/report/statistics/models/slot-statistics.ts b/src/app/modules/admin/report/statistics/models/slot-statistics.ts new file mode 100644 index 0000000..e79f221 --- /dev/null +++ b/src/app/modules/admin/report/statistics/models/slot-statistics.ts @@ -0,0 +1,32 @@ +export interface SlotStatistics { + id: string; + casinoUse?: number; + slotUse?: number; + powerballUse?: number; + casinoBetting?: number; // 카지노배팅 + casinoCancel?: number; // 카지노취소 + casinoAvailable?: number; // 카지노유효 + casinoWinning?: number; // 카지노당첨 + casinoWinLoss?: number; // 카지노윈로스(A) + casinoCommission?: number; // 카지노수수료(B) + casinoBetWinCalculate?: number; // 카지노벳윈정산 (A-B) + slotBetting?: number; // 슬롯배팅 + slotCancel?: number; // 슬롯취소 + slotAvailable?: number; // 슬롯유효 + slotWinning?: number; // 슬롯당첨 + slotWinLoss?: number; // 슬롯윈로스(D) + slotTotalCommission?: number; // 슬롯전체수수료(E) + slotBetWinCalculate?: number; // 슬롯벳윈정산(D-E) + powerballBetting?: number; // 파워볼배팅 + powerballWinning?: number; // 파워볼당첨 + powerballWinLoss?: number; // 파워볼윈로스(H) + powerballCommission?: number; // 파워볼수수료(I) + powerballBetWinCalculate?: number; // 파워볼벳윈정산(H-I) + totalUse?: number; // 총이용회원 + totalAvailable?: number; // 총유효배팅 + totalBetting?: number; // 총배팅 + totalCancel?: number; // 총취소 + totalWinLoss?: number; // 총윈로스 + totalCommission?: number; // 총수수료 + totalBetWinCalculate?: number; // 총벳윈정산 +} diff --git a/src/app/modules/admin/report/statistics/models/statistics.ts b/src/app/modules/admin/report/statistics/models/statistics.ts index 1d95e1e..d2d027f 100644 --- a/src/app/modules/admin/report/statistics/models/statistics.ts +++ b/src/app/modules/admin/report/statistics/models/statistics.ts @@ -1,5 +1,6 @@ export interface Statistics { id: string; + gameName?: string; // 구분 casinoUse?: number; slotUse?: number; powerballUse?: number; diff --git a/src/app/modules/admin/report/statistics/resolvers/statistics.resolver.ts b/src/app/modules/admin/report/statistics/resolvers/statistics.resolver.ts index af676e0..79407fd 100644 --- a/src/app/modules/admin/report/statistics/resolvers/statistics.resolver.ts +++ b/src/app/modules/admin/report/statistics/resolvers/statistics.resolver.ts @@ -8,6 +8,9 @@ import { import { catchError, Observable, throwError } from 'rxjs'; import { Statistics } from '../models/statistics'; +import { CasinoStatistics } from '../models/casino-statistics'; +import { SlotStatistics } from '../models/slot-statistics'; +import { PowerballStatistics } from '../models/powerball-statistics'; import { StatisticsPagination } from '../models/statistics-pagination'; import { StatisticsService } from '../services/statistics.service'; @@ -27,6 +30,12 @@ export class StatisticsResolver implements Resolve { // @ Public methods // ----------------------------------------------------------------------------------------------------- + /** + * Resolver + * + * @param route + * @param state + */ /** * Resolver * @@ -36,9 +45,65 @@ export class StatisticsResolver implements Resolve { resolve( route: ActivatedRouteSnapshot, state: RouterStateSnapshot - ): Observable { + ): Observable<{ + pagination: StatisticsPagination; + statistics: Statistics[]; + }> { + return this._statisticsService.getStatistics(); + } + // resolve( + // route: ActivatedRouteSnapshot, + // state: RouterStateSnapshot + // ): Observable { + // return this._statisticsService + // .getStatisticsById(route.paramMap.get('id')) + // .pipe( + // // Error here means the requested product is not available + // catchError((error) => { + // // Log the error + // console.error(error); + + // // Get the parent url + // const parentUrl = state.url.split('/').slice(0, -1).join('/'); + + // // Navigate to there + // this._router.navigateByUrl(parentUrl); + + // // Throw an error + // return throwError(error); + // }) + // ); + // } +} + +@Injectable({ + providedIn: 'root', +}) +export class CasinoStatisticsResolver implements Resolve { + /** + * Constructor + */ + constructor( + private _statisticsService: StatisticsService, + private _router: Router + ) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): Observable { return this._statisticsService - .getStatisticsById(route.paramMap.get('id')) + .getCasinoStatisticsByType(route.paramMap.get('type')) .pipe( // Error here means the requested product is not available catchError((error) => { @@ -57,15 +122,17 @@ export class StatisticsResolver implements Resolve { ); } } - @Injectable({ providedIn: 'root', }) -export class StatisticssResolver implements Resolve { +export class SlotStatisticsResolver implements Resolve { /** * Constructor */ - constructor(private _statisticsService: StatisticsService) {} + constructor( + private _statisticsService: StatisticsService, + private _router: Router + ) {} // ----------------------------------------------------------------------------------------------------- // @ Public methods @@ -80,10 +147,70 @@ export class StatisticssResolver implements Resolve { resolve( route: ActivatedRouteSnapshot, state: RouterStateSnapshot - ): Observable<{ - pagination: StatisticsPagination; - statisticss: Statistics[]; - }> { - return this._statisticsService.getStatisticss(); + ): Observable { + return this._statisticsService + .getSlotStatisticsByType(route.paramMap.get('type')) + .pipe( + // Error here means the requested product is not available + catchError((error) => { + // Log the error + console.error(error); + + // Get the parent url + const parentUrl = state.url.split('/').slice(0, -1).join('/'); + + // Navigate to there + this._router.navigateByUrl(parentUrl); + + // Throw an error + return throwError(error); + }) + ); + } +} +@Injectable({ + providedIn: 'root', +}) +export class PowerballStatisticsResolver implements Resolve { + /** + * Constructor + */ + constructor( + private _statisticsService: StatisticsService, + private _router: Router + ) {} + + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Resolver + * + * @param route + * @param state + */ + resolve( + route: ActivatedRouteSnapshot, + state: RouterStateSnapshot + ): Observable { + return this._statisticsService + .getPowerballStatisticsByType(route.paramMap.get('type')) + .pipe( + // Error here means the requested product is not available + catchError((error) => { + // Log the error + console.error(error); + + // Get the parent url + const parentUrl = state.url.split('/').slice(0, -1).join('/'); + + // Navigate to there + this._router.navigateByUrl(parentUrl); + + // Throw an error + return throwError(error); + }) + ); } } diff --git a/src/app/modules/admin/report/statistics/services/statistics.service.ts b/src/app/modules/admin/report/statistics/services/statistics.service.ts index f2e2c72..4c08f90 100644 --- a/src/app/modules/admin/report/statistics/services/statistics.service.ts +++ b/src/app/modules/admin/report/statistics/services/statistics.service.ts @@ -13,6 +13,9 @@ import { } from 'rxjs'; import { Statistics } from '../models/statistics'; +import { CasinoStatistics } from '../models/casino-statistics'; +import { SlotStatistics } from '../models/slot-statistics'; +import { PowerballStatistics } from '../models/powerball-statistics'; import { StatisticsPagination } from '../models/statistics-pagination'; @Injectable({ @@ -23,10 +26,18 @@ export class StatisticsService { private __pagination = new BehaviorSubject( undefined ); - private __statistics = new BehaviorSubject(undefined); - private __statisticss = new BehaviorSubject( + private __statistics = new BehaviorSubject( undefined ); + private __casinoStatistics = new BehaviorSubject< + CasinoStatistics | undefined + >(undefined); + private __slotStatistics = new BehaviorSubject( + undefined + ); + private __powerballStatistics = new BehaviorSubject< + PowerballStatistics | undefined + >(undefined); /** * Constructor @@ -43,27 +54,45 @@ export class StatisticsService { get pagination$(): Observable { return this.__pagination.asObservable(); } - /** * Getter for statistics */ - get statistics$(): Observable { + get statistics$(): Observable { return this.__statistics.asObservable(); } /** - * Getter for statisticss + * Getter for casino-statistics */ - get statisticss$(): Observable { - return this.__statisticss.asObservable(); + get casinoStatistics$(): Observable { + return this.__casinoStatistics.asObservable(); } - // ----------------------------------------------------------------------------------------------------- // @ Public methods // ----------------------------------------------------------------------------------------------------- /** - * Get statisticss + * Getter for casino-statistics + */ + get slotStatistics$(): Observable { + return this.__slotStatistics.asObservable(); + } + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Getter for casino-statistics + */ + get powerballStatistics$(): Observable { + return this.__powerballStatistics.asObservable(); + } + // ----------------------------------------------------------------------------------------------------- + // @ Public methods + // ----------------------------------------------------------------------------------------------------- + + /** + * Get statistics * * * @param page @@ -72,21 +101,21 @@ export class StatisticsService { * @param order * @param search */ - getStatisticss( + getStatistics( page: number = 0, size: number = 10, - sort: string = 'name', + sort: string = 'casinoUse', order: 'asc' | 'desc' | '' = 'asc', search: string = '' ): Observable<{ pagination: StatisticsPagination; - statisticss: Statistics[]; + statistics: Statistics[]; }> { return this._httpClient .get<{ pagination: StatisticsPagination; - statisticss: Statistics[]; - }>('api/apps/report/statistics/statisticss', { + statistics: Statistics[]; + }>('api/apps/report/statistics', { params: { page: '' + page, size: '' + size, @@ -98,7 +127,7 @@ export class StatisticsService { .pipe( tap((response) => { this.__pagination.next(response.pagination); - this.__statisticss.next(response.statisticss); + this.__statistics.next(response.statistics); }) ); } @@ -106,13 +135,12 @@ export class StatisticsService { /** * Get product by id */ - getStatisticsById(id: string | null): Observable { - return this.__statisticss.pipe( + getStatisticsById(id: string | null): Observable { + return this.__statistics.pipe( take(1), - map((statisticss) => { + map((statistics) => { // Find the product - const statistics = - statisticss?.find((item) => item.id === id) || undefined; + statistics?.find((item) => item.id === id) || undefined; // Update the product this.__statistics.next(statistics); @@ -130,20 +158,95 @@ export class StatisticsService { ); } + /** + * Get product by type + */ + getCasinoStatisticsByType(type: string | null): Observable { + return this.__statistics.pipe( + take(1), + map((statistics) => { + // Find the product + const casinoStatistics = + statistics?.find((item) => item.id === type) || undefined; + + // Update the product + this.__casinoStatistics.next(casinoStatistics); + + // Return the product + return casinoStatistics; + }), + switchMap((product) => { + if (!product) { + return throwError('Could not found product with id of ' + type + '!'); + } + + return of(product); + }) + ); + } + getSlotStatisticsByType(type: string | null): Observable { + return this.__statistics.pipe( + take(1), + map((statistics) => { + // Find the product + const slotStatistics = + statistics?.find((item) => item.id === type) || undefined; + + // Update the product + this.__slotStatistics.next(slotStatistics); + + // Return the product + return slotStatistics; + }), + switchMap((product) => { + if (!product) { + return throwError('Could not found product with id of ' + type + '!'); + } + + return of(product); + }) + ); + } + getPowerballStatisticsByType( + type: string | null + ): Observable { + return this.__statistics.pipe( + take(1), + map((statistics) => { + // Find the product + const powerballStatistics = + statistics?.find((item) => item.id === type) || undefined; + + // Update the product + this.__powerballStatistics.next(powerballStatistics); + + // Return the product + return powerballStatistics; + }), + switchMap((product) => { + if (!product) { + return throwError('Could not found product with id of ' + type + '!'); + } + + return of(product); + }) + ); + } + /** * Create product */ createStatistics(): Observable { - return this.statisticss$.pipe( + return this.statistics$.pipe( take(1), - switchMap((statisticss) => + switchMap((statistics) => this._httpClient .post('api/apps/report/statistics/product', {}) .pipe( map((newStatistics) => { - // Update the statisticss with the new product - if (!!statisticss) { - this.__statisticss.next([newStatistics, ...statisticss]); + // Update the statistics with the new product + if (!!statistics) { + this.__statistics.next([newStatistics, ...statistics]); } // Return the new product diff --git a/src/app/modules/admin/report/statistics/statistics.routing.ts b/src/app/modules/admin/report/statistics/statistics.routing.ts index 9a4b51c..eedda3a 100644 --- a/src/app/modules/admin/report/statistics/statistics.routing.ts +++ b/src/app/modules/admin/report/statistics/statistics.routing.ts @@ -3,7 +3,7 @@ import { Route } from '@angular/router'; import { ListComponent } from './components/list.component'; import { ViewComponent } from '../../member/user/components/view.component'; -import { StatisticssResolver } from './resolvers/statistics.resolver'; +import { StatisticsResolver } from './resolvers/statistics.resolver'; import { UserResolver } from '../../member/user/resolvers/user.resolver'; export const statisticsRoutes: Route[] = [ @@ -11,7 +11,7 @@ export const statisticsRoutes: Route[] = [ path: '', component: ListComponent, resolve: { - statisticss: StatisticssResolver, + statistics: StatisticsResolver, }, }, {