parent
10ad10d922
commit
00a47756b2
@ -108,6 +108,7 @@ export class ProductModalComponent implements OnInit {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.cartService.changeTerminal(this.config.data.selectedTerminal)
|
||||||
this.cartService.addToCart(this.cartProduct);
|
this.cartService.addToCart(this.cartProduct);
|
||||||
this.dialogRef.close();
|
this.dialogRef.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import { GetTerminalsService } from 'src/app/services/get-terminals.service';
|
|||||||
export class UserDataOrderComponent implements OnInit, OnDestroy {
|
export class UserDataOrderComponent implements OnInit, OnDestroy {
|
||||||
|
|
||||||
@Output() orderSubmitted = new EventEmitter<number>();
|
@Output() orderSubmitted = new EventEmitter<number>();
|
||||||
|
@Output() userNotFound = new EventEmitter<null>();
|
||||||
readonly cities = environment.cities;
|
readonly cities = environment.cities;
|
||||||
public paymentMethods!: PaymentMethod[];
|
public paymentMethods!: PaymentMethod[];
|
||||||
public loading = false;
|
public loading = false;
|
||||||
@ -229,6 +230,9 @@ export class UserDataOrderComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
private async _createUserDataForm(): Promise<FormGroup> {
|
private async _createUserDataForm(): Promise<FormGroup> {
|
||||||
this.order = await this.orderService.getOrder(true);
|
this.order = await this.orderService.getOrder(true);
|
||||||
|
if (this.order.userData?.errorCode === "Customer_CustomerNotFound") {
|
||||||
|
this.userNotFound.emit(null)
|
||||||
|
}
|
||||||
this.userData = Object.assign({}, this.userData, this.order.userData);
|
this.userData = Object.assign({}, this.userData, this.order.userData);
|
||||||
this.userData.city = this.cities[0];
|
this.userData.city = this.cities[0];
|
||||||
this.userData.phone = this.order.phone;
|
this.userData.phone = this.order.phone;
|
||||||
|
|||||||
@ -252,7 +252,8 @@ export interface UserData {
|
|||||||
city: string;
|
city: string;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
selectedTerminal: ITerminal | null;
|
selectedTerminal: ITerminal | null;
|
||||||
name: string
|
name: string;
|
||||||
|
errorCode?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface ITerminal {
|
export interface ITerminal {
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import { environment } from "src/environments/environment";
|
|||||||
|
|
||||||
export interface OrderInfo {
|
export interface OrderInfo {
|
||||||
products: OrderProduct[];
|
products: OrderProduct[];
|
||||||
userData?: UserData;
|
userData: UserData | null;
|
||||||
deliveryData?: DeliveryData;
|
deliveryData?: DeliveryData;
|
||||||
phone: string;
|
phone: string;
|
||||||
token: string | undefined;
|
token: string | undefined;
|
||||||
@ -16,7 +16,7 @@ export interface OrderInfo {
|
|||||||
export class Order {
|
export class Order {
|
||||||
|
|
||||||
public products: OrderProduct[];
|
public products: OrderProduct[];
|
||||||
public userData?: UserData;
|
public userData!: UserData | null;
|
||||||
public deliveryData?: DeliveryData;
|
public deliveryData?: DeliveryData;
|
||||||
public phone: string;
|
public phone: string;
|
||||||
public token: string | undefined;
|
public token: string | undefined;
|
||||||
|
|||||||
@ -15,6 +15,9 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-container__content">
|
<div class="card-container__content">
|
||||||
<div class="info">
|
<div class="info">
|
||||||
|
<div *ngIf="!accountData && !loadingBonuses" class="info__row">
|
||||||
|
Пользователь не найден, обратитесь к руководству
|
||||||
|
</div>
|
||||||
<div *ngIf="accountData" class="info__row">
|
<div *ngIf="accountData" class="info__row">
|
||||||
<span class="key">Имя</span>
|
<span class="key">Имя</span>
|
||||||
<span class="value" *ngIf="userName.length">{{
|
<span class="value" *ngIf="userName.length">{{
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import { CookiesService } from 'src/app/services/cookies.service';
|
|||||||
import { DOCUMENT } from '@angular/common';
|
import { DOCUMENT } from '@angular/common';
|
||||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||||
import { WpJsonService } from 'src/app/services/wp-json.service';
|
import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-bonus-program',
|
selector: 'app-bonus-program',
|
||||||
@ -36,6 +37,7 @@ export class BonusProgramComponent implements OnInit {
|
|||||||
@Inject(DOCUMENT) private document: Document,
|
@Inject(DOCUMENT) private document: Document,
|
||||||
private http: HttpClient,
|
private http: HttpClient,
|
||||||
private wpJsonService: WpJsonService,
|
private wpJsonService: WpJsonService,
|
||||||
|
private _snackBar: MatSnackBar
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
|
|
||||||
@ -55,6 +57,11 @@ export class BonusProgramComponent implements OnInit {
|
|||||||
this.loadingBonuses = true;
|
this.loadingBonuses = true;
|
||||||
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({
|
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({
|
||||||
next: (res) => {
|
next: (res) => {
|
||||||
|
if (res.customer_info.errorCode === 'Customer_CustomerNotFound') {
|
||||||
|
// this._snackBar.open('Пользователь не найден в системе! Обратитесь к руководству', 'Ок')
|
||||||
|
this.loadingBonuses = false;
|
||||||
|
return
|
||||||
|
}
|
||||||
this.userName = res.customer_info.name
|
this.userName = res.customer_info.name
|
||||||
this.accountData = {
|
this.accountData = {
|
||||||
CardNumber: res.customer_info.cards[0]?.Number || '',
|
CardNumber: res.customer_info.cards[0]?.Number || '',
|
||||||
|
|||||||
@ -46,6 +46,10 @@ export class OrdersComponent implements OnInit {
|
|||||||
const customerInfo = (await lastValueFrom(
|
const customerInfo = (await lastValueFrom(
|
||||||
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy)
|
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy)
|
||||||
))
|
))
|
||||||
|
if (customerInfo.customer_info.errorCode === 'Customer_CustomerNotFound') {
|
||||||
|
this.ordersLoadingStatus = false;
|
||||||
|
return
|
||||||
|
}
|
||||||
const purchases: Purchase[] = (await lastValueFrom(
|
const purchases: Purchase[] = (await lastValueFrom(
|
||||||
this.wpJsonService.getTransactions(environment.systemId, token, environment.icardProxy, 30)
|
this.wpJsonService.getTransactions(environment.systemId, token, environment.icardProxy, 30)
|
||||||
))[customerInfo.customer_info.id];
|
))[customerInfo.customer_info.id];
|
||||||
|
|||||||
@ -154,47 +154,12 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<p-toast
|
|
||||||
position="bottom-center"
|
|
||||||
key="c"
|
|
||||||
(onClose)="onReject()"
|
|
||||||
[baseZIndex]="5000"
|
|
||||||
>
|
|
||||||
<ng-template let-message pTemplate="message">
|
|
||||||
<div class="flex flex-column" style="flex: 1">
|
|
||||||
<div class="text-center">
|
|
||||||
<i class="pi pi-exclamation-triangle" style="font-size: 3rem"></i>
|
|
||||||
<h4>{{ message.summary }}</h4>
|
|
||||||
<p style="font-weight: 600">{{ message.detail }}</p>
|
|
||||||
</div>
|
|
||||||
<div class="grid p-fluid">
|
|
||||||
<div class="col-6">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
pButton
|
|
||||||
(click)="onConfirm()"
|
|
||||||
label="Да"
|
|
||||||
class="p-button-success"
|
|
||||||
></button>
|
|
||||||
</div>
|
|
||||||
<div class="col-6">
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
pButton
|
|
||||||
(click)="onReject()"
|
|
||||||
label="Нет"
|
|
||||||
class="p-button-secondary"
|
|
||||||
></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</ng-template>
|
|
||||||
</p-toast>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<app-user-data-order
|
<app-user-data-order
|
||||||
*ngIf="orderConfirmed"
|
*ngIf="orderConfirmed"
|
||||||
(orderSubmitted)="orderSubmitted($event)"
|
(orderSubmitted)="orderSubmitted($event)"
|
||||||
|
(userNotFound)="userNotFound($event)"
|
||||||
></app-user-data-order>
|
></app-user-data-order>
|
||||||
|
|
||||||
<div #loadingEl *ngIf="loading && !orderConfirmed">
|
<div #loadingEl *ngIf="loading && !orderConfirmed">
|
||||||
|
|||||||
@ -72,10 +72,19 @@ export class CartComponent implements OnInit {
|
|||||||
async loadCart(): Promise<void> {
|
async loadCart(): Promise<void> {
|
||||||
this.loading = true;
|
this.loading = true;
|
||||||
this.order = await this.orderService.getOrder(true);
|
this.order = await this.orderService.getOrder(true);
|
||||||
|
if (this.order?.userData?.errorCode === 'Customer_CustomerNotFound') {
|
||||||
|
this.userNotFound()
|
||||||
|
return
|
||||||
|
}
|
||||||
if (this.order) this.price = this.order.price;
|
if (this.order) this.price = this.order.price;
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
userNotFound(event: null = null) {
|
||||||
|
this.visibleSidebar = false
|
||||||
|
this._snackBar.open('Пользователь не найден в системе! Обратитесь к руководству', 'Ок')
|
||||||
|
}
|
||||||
|
|
||||||
removeFromCart(event: Event, guid: string): void {
|
removeFromCart(event: Event, guid: string): void {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
this.orderService.removeFromCart(guid);
|
this.orderService.removeFromCart(guid);
|
||||||
@ -125,17 +134,5 @@ export class CartComponent implements OnInit {
|
|||||||
this.visibleSidebar = false;
|
this.visibleSidebar = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// this.messageService.add({ key: 'c', sticky: true, severity: 'warn', summary: 'Вы уверены, что хотите очистить корзину?' });
|
|
||||||
}
|
|
||||||
|
|
||||||
onReject() {
|
|
||||||
this.messageService.clear('c');
|
|
||||||
}
|
|
||||||
|
|
||||||
onConfirm() {
|
|
||||||
this.cartService.clearCart();
|
|
||||||
this.loadCart();
|
|
||||||
this.visibleSidebar = false;
|
|
||||||
this.messageService.clear('c');
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="products-container__items">
|
<div class="products-container__items">
|
||||||
<div
|
<div
|
||||||
*ngFor="let product of filterByGroup(group)"
|
*ngFor="let product of filterByGroup(group); trackBy: trackProducts"
|
||||||
(click)="addToCart($event, product)"
|
(click)="addToCart($event, product)"
|
||||||
class="products-container__item"
|
class="products-container__item"
|
||||||
#currentCategoryList
|
#currentCategoryList
|
||||||
@ -72,7 +72,7 @@
|
|||||||
<ng-container *ngIf="selectedGroup && selectedGroup.label !== 'Все'">
|
<ng-container *ngIf="selectedGroup && selectedGroup.label !== 'Все'">
|
||||||
<div class="products-container__items">
|
<div class="products-container__items">
|
||||||
<div
|
<div
|
||||||
*ngFor="let product of filterByGroup()"
|
*ngFor="let product of filterByGroup(); trackBy: trackProducts"
|
||||||
(click)="addToCart($event, product)"
|
(click)="addToCart($event, product)"
|
||||||
class="products-container__item"
|
class="products-container__item"
|
||||||
#currentCategoryList
|
#currentCategoryList
|
||||||
|
|||||||
@ -141,6 +141,7 @@ export class ProductsComponent implements OnInit {
|
|||||||
product: product,
|
product: product,
|
||||||
modifiersGroups: this.modifiersGroups,
|
modifiersGroups: this.modifiersGroups,
|
||||||
modifiers: this.modifiers,
|
modifiers: this.modifiers,
|
||||||
|
selectedTerminal: this.selectedTerminal
|
||||||
},
|
},
|
||||||
baseZIndex: 10000,
|
baseZIndex: 10000,
|
||||||
autoZIndex: true,
|
autoZIndex: true,
|
||||||
@ -182,4 +183,8 @@ export class ProductsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
this.currentPage = 0;
|
this.currentPage = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trackProducts(index: number, product: Product) {
|
||||||
|
return product.id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -52,6 +52,20 @@ export class OrderService {
|
|||||||
// RpcService.authService,
|
// RpcService.authService,
|
||||||
// true
|
// true
|
||||||
// );
|
// );
|
||||||
|
const terminal =
|
||||||
|
JSON.parse(
|
||||||
|
this.cookiesService.getItem('selectedTerminal') || 'null'
|
||||||
|
) || this.cartService.selectedTerminal$;
|
||||||
|
if (!token.length) {
|
||||||
|
this.order = new Order({
|
||||||
|
products: products,
|
||||||
|
userData: null,
|
||||||
|
phone: '',
|
||||||
|
token: token,
|
||||||
|
terminal_id: terminal.id,
|
||||||
|
});
|
||||||
|
return this.order;
|
||||||
|
}
|
||||||
const additionalInfo = this.wpJsonService.getCustomerInfo(
|
const additionalInfo = this.wpJsonService.getCustomerInfo(
|
||||||
environment.systemId,
|
environment.systemId,
|
||||||
token,
|
token,
|
||||||
@ -70,12 +84,8 @@ export class OrderService {
|
|||||||
const info = await lastValueFrom(
|
const info = await lastValueFrom(
|
||||||
forkJoin([additionalInfo, tokenData, products])
|
forkJoin([additionalInfo, tokenData, products])
|
||||||
);
|
);
|
||||||
const customer_info = info[0]?.customer_info
|
const customer_info = info[0]?.customer_info;
|
||||||
|
|
||||||
const terminal =
|
|
||||||
JSON.parse(
|
|
||||||
this.cookiesService.getItem('selectedTerminal') || 'null'
|
|
||||||
) || this.cartService.selectedTerminal$;
|
|
||||||
this.order = new Order({
|
this.order = new Order({
|
||||||
products: products,
|
products: products,
|
||||||
userData: customer_info,
|
userData: customer_info,
|
||||||
@ -92,12 +102,14 @@ export class OrderService {
|
|||||||
|
|
||||||
async getProducts(cart: Cart): Promise<OrderProduct[]> {
|
async getProducts(cart: Cart): Promise<OrderProduct[]> {
|
||||||
const terminal =
|
const terminal =
|
||||||
JSON.parse(this.cookiesService.getItem('selectedTerminal') || 'null') ||
|
JSON.parse(this.cookiesService.getItem('selectedTerminal') || 'null');
|
||||||
this.cartService.selectedTerminal$;
|
const products: OrderProduct[] = [];
|
||||||
|
if (!terminal) {
|
||||||
|
return products
|
||||||
|
}
|
||||||
const allData = await lastValueFrom(
|
const allData = await lastValueFrom(
|
||||||
this.wpJsonService.getAllData(`${terminal.label}${terminal.id}`)
|
this.wpJsonService.getAllData(`${terminal.label}${terminal.id}`)
|
||||||
);
|
);
|
||||||
const products: OrderProduct[] = [];
|
|
||||||
for (let i = 0; i < cart.products.length; i++) {
|
for (let i = 0; i < cart.products.length; i++) {
|
||||||
const productSub = allData.products.find(
|
const productSub = allData.products.find(
|
||||||
(product: any) => product.id === cart.products[i].id
|
(product: any) => product.id === cart.products[i].id
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user