IMP-163: Added payments external id filter (#179)

This commit is contained in:
Rinat Arsaev 2024-03-28 19:50:02 +07:00 committed by GitHub
parent 31b1198cf8
commit 27cdf3c170
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 43 additions and 66 deletions

View File

@ -14,5 +14,9 @@
<mat-label>{{ t('rrn') }}</mat-label>
<input aria-label="rrn" formControlName="rrn" matInput />
</mat-form-field>
<mat-form-field>
<mat-label>{{ t('externalID') }}</mat-label>
<input aria-label="externalID" formControlName="externalID" matInput />
</mat-form-field>
</form>
</ng-container>

View File

@ -15,6 +15,7 @@ export class MainFiltersComponent extends FormGroupSuperclass<Partial<MainFilter
payerEmail: ['', Validators.email],
customerID: [''],
rrn: ['', Validators.pattern(new RegExp(/^\d+$/))],
externalID: [''],
});
constructor(private fb: FormBuilder) {

View File

@ -2,4 +2,5 @@ export interface MainFiltersForm {
payerEmail: string;
customerID: string;
rrn: string;
externalID: string;
}

View File

@ -4,6 +4,7 @@ export const filtersToForm = ({
payerEmail = null,
customerID = null,
rrn = null,
externalID = null,
paymentStatus = null,
paymentAmountFrom = null,
paymentAmountTo = null,
@ -17,6 +18,7 @@ export const filtersToForm = ({
payerEmail,
customerID,
rrn,
externalID,
},
paymentStatus,
paymentSum: {

View File

@ -1,26 +1,19 @@
import { Component, OnInit } from '@angular/core';
import { UntilDestroy, untilDestroyed } from '@ngneat/until-destroy';
import { Component, DestroyRef, OnInit, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { QueryParamsService } from '@vality/ng-core';
import { PaymentSearchResult } from '@vality/swag-anapi-v2';
import { PaymentSearchResult, SearchPaymentsRequestParams } from '@vality/swag-anapi-v2';
import { Observable } from 'rxjs';
import { take, skip } from 'rxjs/operators';
import { RealmMixService } from '../../services';
import { PaymentInstitutionRealmService } from '../../services/payment-institution-realm.service';
import { Filters } from './payments-filters';
import { PaymentsExpandedIdManager, FetchPaymentsService } from './services';
import { PaymentSearchFormValue } from './types';
@UntilDestroy()
@Component({
selector: 'dsh-payments',
templateUrl: 'payments.component.html',
providers: [
FetchPaymentsService,
PaymentsExpandedIdManager,
RealmMixService,
PaymentInstitutionRealmService,
],
providers: [FetchPaymentsService, PaymentsExpandedIdManager, PaymentInstitutionRealmService],
})
export class PaymentsComponent implements OnInit {
realm$ = this.paymentInstitutionRealmService.realm$;
@ -30,19 +23,22 @@ export class PaymentsComponent implements OnInit {
lastUpdated$: Observable<string> = this.paymentsService.lastUpdated$;
expandedId$: Observable<number> = this.expandedIdManager.expandedId$;
initParams$ = this.qp.params$;
filters = signal<Filters>(null);
constructor(
private paymentsService: FetchPaymentsService,
private expandedIdManager: PaymentsExpandedIdManager,
private paymentInstitutionRealmService: PaymentInstitutionRealmService,
private qp: QueryParamsService<Filters>,
private realmMixService: RealmMixService<PaymentSearchFormValue>,
private destroyRef: DestroyRef,
) {}
ngOnInit(): void {
this.realmMixService.mixedValue$
.pipe(untilDestroyed(this))
.subscribe((v) => this.paymentsService.search(v));
ngOnInit() {
this.paymentInstitutionRealmService.realm$
.pipe(skip(1), takeUntilDestroyed(this.destroyRef))
.subscribe(() => {
this.filtersChanged();
});
}
refreshList(): void {
@ -53,11 +49,12 @@ export class PaymentsComponent implements OnInit {
this.paymentsService.fetchMore();
}
filtersChanged(filters: Filters): void {
filtersChanged(filters: Filters = this.filters()): void {
this.filters.set(filters);
void this.qp.set(filters);
// TODO: refactor additional filters
const { dateRange, binPan, ...otherFilters } = filters;
const paymentMethod: Partial<PaymentSearchFormValue> =
const paymentMethod: Partial<SearchPaymentsRequestParams> =
binPan?.bin || binPan?.pan ? { paymentMethod: 'bankCard' } : {};
if (binPan?.bin) {
paymentMethod.first6 = binPan.bin;
@ -65,13 +62,17 @@ export class PaymentsComponent implements OnInit {
if (binPan?.pan) {
paymentMethod.last4 = binPan.pan;
}
this.realmMixService.mix({
...otherFilters,
...paymentMethod,
fromTime: dateRange.start.clone().utc().format(),
toTime: dateRange.end.clone().utc().format(),
realm: null,
});
this.paymentInstitutionRealmService.realm$
.pipe(take(1), takeUntilDestroyed(this.destroyRef))
.subscribe((paymentInstitutionRealm) => {
this.paymentsService.search({
...otherFilters,
...paymentMethod,
fromTime: dateRange.start.clone().utc().format(),
toTime: dateRange.end.clone().utc().format(),
paymentInstitutionRealm,
});
});
}
expandedIdChange(id: number): void {

View File

@ -1,7 +1,7 @@
import { Inject, Injectable } from '@angular/core';
import { TranslocoService } from '@ngneat/transloco';
import { NotifyLogService } from '@vality/ng-core';
import { PaymentSearchResult } from '@vality/swag-anapi-v2';
import { PaymentSearchResult, SearchPaymentsRequestParams } from '@vality/swag-anapi-v2';
import { isNumber } from 'lodash-es';
import { Observable, of } from 'rxjs';
import { catchError, shareReplay } from 'rxjs/operators';
@ -11,12 +11,10 @@ import { mapToTimestamp } from '@dsh/app/custom-operators';
import { SEARCH_LIMIT } from '@dsh/app/sections/tokens';
import { DEBOUNCE_FETCHER_ACTION_TIME, PartialFetcher } from '@dsh/app/shared';
import { PaymentSearchFormValue } from '../../types';
@Injectable()
export class FetchPaymentsService extends PartialFetcher<
PaymentSearchResult,
PaymentSearchFormValue
Omit<Parameters<SearchService['searchPayments']>[0], 'limit'>
> {
isLoading$: Observable<boolean> = this.doAction$.pipe(shareReplay(1));
lastUpdated$: Observable<string> = this.searchResult$.pipe(mapToTimestamp, shareReplay(1));
@ -35,13 +33,12 @@ export class FetchPaymentsService extends PartialFetcher<
}
protected fetch(
{ paymentAmountFrom, paymentAmountTo, realm, ...params }: PaymentSearchFormValue,
{ paymentAmountFrom, paymentAmountTo, ...params }: SearchPaymentsRequestParams,
continuationToken?: string,
) {
return this.searchService
.searchPayments({
...params,
paymentInstitutionRealm: realm,
paymentAmountFrom: isNumber(paymentAmountFrom) ? paymentAmountFrom : undefined,
paymentAmountTo: isNumber(paymentAmountTo) ? paymentAmountTo : undefined,
limit: this.searchLimit,

View File

@ -1,2 +1 @@
export * from './payment-ids';
export * from './payment-search-form-value';

View File

@ -1,33 +0,0 @@
import { SearchPaymentsRequestParams } from '@vality/swag-anapi-v2';
import { PaymentInstitution } from '@vality/swag-payments';
import RealmEnum = PaymentInstitution.RealmEnum;
export interface PaymentSearchFormValue
extends Pick<
SearchPaymentsRequestParams,
| 'paymentStatus'
| 'paymentTerminalProvider'
| 'bankCardTokenProvider'
| 'bankCardPaymentSystem'
| 'paymentMethod'
| 'paymentFlow'
> {
realm: RealmEnum;
fromTime: string;
toTime: string;
shopIDs?: string[];
invoiceIDs?: string[];
invoiceID?: string;
paymentID?: string;
payerEmail?: string;
payerIP?: string;
payerFingerprint?: string;
customerID?: string;
first6?: string;
last4?: string;
paymentAmount?: number;
rrn?: string;
paymentAmountFrom?: number;
paymentAmountTo?: number;
}

View File

@ -7,6 +7,9 @@ import { PaymentInstitutionRealmService } from './payment-institution-realm.serv
import RealmEnum = PaymentInstitution.RealmEnum;
/**
* @deprecated
*/
@Injectable()
export class RealmMixService<T> {
mixedValue$: Observable<T & { realm: RealmEnum }>;

View File

@ -169,6 +169,7 @@
"binPan": "Card",
"card": "Card",
"customerID": "Customer ID",
"externalID": "External ID",
"first6": "Card issuing bank BIN",
"invoices": "Invoices",
"last4": "Card last digits",

View File

@ -169,6 +169,7 @@
"binPan": "Карта",
"card": "Карта",
"customerID": "Идентификатор плательщика",
"externalID": "Внешний идентификатор",
"first6": "BIN банка-эмитента карты",
"invoices": "Инвойсы",
"last4": "Последние цифры номера карты",