#4485 #4500 Kundenkartenkonto anlage Verhalten and Suche angeglichen

This commit is contained in:
Lorenz Hilpert
2023-12-15 14:34:24 +01:00
parent a8cd6ce844
commit 4ab9890313
11 changed files with 83 additions and 36 deletions

View File

@@ -7,7 +7,7 @@ import { CrmCustomerService } from '@domain/crm';
import { AddressDTO, CustomerDTO, CustomerInfoDTO, PayerDTO, ShippingAddressDTO } from '@swagger/crm';
import { UiErrorModalComponent, UiModalService } from '@ui/modal';
import { UiValidators } from '@ui/validators';
import { isNull } from 'lodash';
import { isNull, merge } from 'lodash';
import { BehaviorSubject, Observable, of, Subject } from 'rxjs';
import {
first,
@@ -229,7 +229,45 @@ export abstract class AbstractCreateCustomer implements OnInit, OnDestroy {
const customerId = this.formData?._meta?.customerDto?.id ?? this.formData?._meta?.customerInfoDto?.id;
return this.customerService.checkLoyaltyCard({ loyaltyCardNumber: value, customerId }).pipe(
map((response) => {
return !response?.error && (response as any)?.result === 1 ? null : { invalid: 'Kundenkartencode ist ungültig' };
if (response.error) {
throw response.message;
}
if (response.result && response.result.customer) {
const customer = response.result.customer;
const current = this.formData;
const data = mapCustomerInfoDtoToCustomerCreateFormData(customer);
data.name = {
firstName: current.name?.firstName || data.name?.firstName,
gender: current.name?.gender || data.name?.gender,
lastName: current.name?.lastName || data.name?.lastName,
title: current.name?.title || data.name?.title,
};
data.address = {
city: current.address?.city || data.address?.city,
country: current.address?.country || data.address?.country,
street: current.address?.street || data.address?.street,
zipCode: current.address?.zipCode || data.address?.zipCode,
info: current.address?.info || data.address?.info,
streetNumber: current.address?.streetNumber || data.address?.streetNumber,
};
data.email = current.email || data.email;
data.phoneNumbers = {
mobile: current.phoneNumbers?.mobile || data.phoneNumbers?.mobile,
phone: current.phoneNumbers?.phone || data.phoneNumbers?.phone,
};
data.birthDate = current.birthDate || data.birthDate;
data.agb = current.agb || data.agb;
this._formData.next(data);
}
return null;
}),
catchError((error) => {
if (error instanceof HttpErrorResponse) {
@@ -242,31 +280,13 @@ export abstract class AbstractCreateCustomer implements OnInit, OnDestroy {
})
);
}),
tap(async (result) => {
tap(() => {
control.markAsTouched();
this.cdr.markForCheck();
if (result === null) {
const customerInfoDto = await this.getAnonymousCustomerForCode(control.value);
if (customerInfoDto) {
const data = mapCustomerInfoDtoToCustomerCreateFormData(customerInfoDto);
this._formData.next(data);
}
}
})
);
};
async getAnonymousCustomerForCode(code: string): Promise<CustomerInfoDTO | undefined> {
try {
const res = await this.customerService.getCustomers(code).toPromise();
if (res.result.length > 0 && res.result[0].id < 0) {
return res.result[0];
}
} catch (error) {}
}
async navigateToCustomerDetails(customer: CustomerDTO) {
const processId = await this.processId$.pipe(first()).toPromise();
const route = this.customerSearchNavigation.detailsRoute({ processId, customerId: customer.id, customer });

View File

@@ -7,7 +7,6 @@ export { DialogOfString } from './models/dialog-of-string';
export { DialogSettings } from './models/dialog-settings';
export { DialogContentType } from './models/dialog-content-type';
export { KeyValueDTOOfStringAndString } from './models/key-value-dtoof-string-and-string';
export { IPublicUserInfo } from './models/ipublic-user-info';
export { ProblemDetails } from './models/problem-details';
export { ResponseArgsOfIEnumerableOfCountryDTO } from './models/response-args-of-ienumerable-of-country-dto';
export { CountryDTO } from './models/country-dto';
@@ -15,6 +14,7 @@ export { EntityDTOBaseOfCountryDTOAndICountry } from './models/entity-dtobase-of
export { EntityDTOBase } from './models/entity-dtobase';
export { EntityDTO } from './models/entity-dto';
export { EntityStatus } from './models/entity-status';
export { CRUDA } from './models/cruda';
export { ResponseArgsOfInputDTO } from './models/response-args-of-input-dto';
export { InputDTO } from './models/input-dto';
export { InputType } from './models/input-type';
@@ -92,5 +92,8 @@ export { DiffDTO } from './models/diff-dto';
export { ResponseArgsOfIEnumerableOfEntityKeyValueDTOOfStringAndString } from './models/response-args-of-ienumerable-of-entity-key-value-dtoof-string-and-string';
export { EntityKeyValueDTOOfStringAndString } from './models/entity-key-value-dtoof-string-and-string';
export { ResponseArgsOfIEnumerableOfKeyValueDTOOfStringAndString } from './models/response-args-of-ienumerable-of-key-value-dtoof-string-and-string';
export { ResponseArgsOfCheckLoyaltyCardResult } from './models/response-args-of-check-loyalty-card-result';
export { CheckLoyaltyCardResult } from './models/check-loyalty-card-result';
export { LoyaltyCardStatus } from './models/loyalty-card-status';
export { ResponseArgsOfPayerDTO } from './models/response-args-of-payer-dto';
export { ResponseArgsOfShippingAddressDTO } from './models/response-args-of-shipping-address-dto';

View File

@@ -0,0 +1,15 @@
/* tslint:disable */
import { CustomerInfoDTO } from './customer-info-dto';
import { LoyaltyCardStatus } from './loyalty-card-status';
export interface CheckLoyaltyCardResult {
/**
* Customer
*/
customer?: CustomerInfoDTO;
/**
* Status
*/
status: LoyaltyCardStatus;
}

View File

@@ -0,0 +1,2 @@
/* tslint:disable */
export type CRUDA = 0 | 1 | 2 | 4 | 8 | 16;

View File

@@ -1,11 +1,14 @@
/* tslint:disable */
import { TouchedBase } from './touched-base';
import { CRUDA } from './cruda';
import { EntityStatus } from './entity-status';
export interface EntityDTO extends TouchedBase{
changed?: string;
created?: string;
cruda?: CRUDA;
id?: number;
pId?: string;
status?: EntityStatus;
uId?: string;
version?: number;
}

View File

@@ -8,4 +8,5 @@ export interface EntityDTOReferenceContainer extends TouchedBase{
id?: number;
pId?: string;
selected?: boolean;
uId?: string;
}

View File

@@ -1,7 +0,0 @@
/* tslint:disable */
export interface IPublicUserInfo {
alias?: string;
displayName?: string;
isAuthenticated: boolean;
username?: string;
}

View File

@@ -0,0 +1,6 @@
/* tslint:disable */
/**
* Kundenkartenstatus
*/
export type LoyaltyCardStatus = 0 | 1 | 2 | 4 | 8;

View File

@@ -0,0 +1,6 @@
/* tslint:disable */
import { ResponseArgs } from './response-args';
import { CheckLoyaltyCardResult } from './check-loyalty-card-result';
export interface ResponseArgsOfCheckLoyaltyCardResult extends ResponseArgs{
result?: CheckLoyaltyCardResult;
}

View File

@@ -1,11 +1,9 @@
/* tslint:disable */
import { DialogOfString } from './dialog-of-string';
import { IPublicUserInfo } from './ipublic-user-info';
export interface ResponseArgs {
dialog?: DialogOfString;
error: boolean;
invalidProperties?: {[key: string]: string};
message?: string;
requestId?: number;
userInfo?: IPublicUserInfo;
}

View File

@@ -9,7 +9,7 @@ import { map as __map, filter as __filter } from 'rxjs/operators';
import { ResponseArgsOfIEnumerableOfEntityKeyValueDTOOfStringAndString } from '../models/response-args-of-ienumerable-of-entity-key-value-dtoof-string-and-string';
import { ResponseArgsOfIEnumerableOfKeyValueDTOOfStringAndString } from '../models/response-args-of-ienumerable-of-key-value-dtoof-string-and-string';
import { ResponseArgsOfQuerySettingsDTO } from '../models/response-args-of-query-settings-dto';
import { ResponseArgsOfCheckLoyaltyCardResult } from '../models/response-args-of-check-loyalty-card-result';
@Injectable({
providedIn: 'root',
})
@@ -121,7 +121,7 @@ class LoyaltyCardService extends __BaseService {
*
* - `customerId`: PK Kunde (optional)
*/
LoyaltyCardCheckLoyaltyCardResponse(params: LoyaltyCardService.LoyaltyCardCheckLoyaltyCardParams): __Observable<__StrictHttpResponse<ResponseArgsOfQuerySettingsDTO>> {
LoyaltyCardCheckLoyaltyCardResponse(params: LoyaltyCardService.LoyaltyCardCheckLoyaltyCardParams): __Observable<__StrictHttpResponse<ResponseArgsOfCheckLoyaltyCardResult>> {
let __params = this.newParams();
let __headers = new HttpHeaders();
let __body: any = null;
@@ -141,7 +141,7 @@ class LoyaltyCardService extends __BaseService {
return this.http.request<any>(req).pipe(
__filter(_r => _r instanceof HttpResponse),
__map((_r) => {
return _r as __StrictHttpResponse<ResponseArgsOfQuerySettingsDTO>;
return _r as __StrictHttpResponse<ResponseArgsOfCheckLoyaltyCardResult>;
})
);
}
@@ -155,9 +155,9 @@ class LoyaltyCardService extends __BaseService {
*
* - `customerId`: PK Kunde (optional)
*/
LoyaltyCardCheckLoyaltyCard(params: LoyaltyCardService.LoyaltyCardCheckLoyaltyCardParams): __Observable<ResponseArgsOfQuerySettingsDTO> {
LoyaltyCardCheckLoyaltyCard(params: LoyaltyCardService.LoyaltyCardCheckLoyaltyCardParams): __Observable<ResponseArgsOfCheckLoyaltyCardResult> {
return this.LoyaltyCardCheckLoyaltyCardResponse(params).pipe(
__map(_r => _r.body as ResponseArgsOfQuerySettingsDTO)
__map(_r => _r.body as ResponseArgsOfCheckLoyaltyCardResult)
);
}
}