parent
2fa05b391e
commit
6c283812e7
@ -15,7 +15,7 @@
|
|||||||
<div class="guest-card__qr" (click)="qrCodeClick()">
|
<div class="guest-card__qr" (click)="qrCodeClick()">
|
||||||
<ng-container *ngIf="customerInfo">
|
<ng-container *ngIf="customerInfo">
|
||||||
<qr-code
|
<qr-code
|
||||||
[value]="customerInfo?.phone.substr(2) || 'Данные не найдены'"
|
[value]="customerInfo?.phone?.substr(2) || 'Данные не найдены'"
|
||||||
[margin]="0"
|
[margin]="0"
|
||||||
[size]="qrCodeSize"
|
[size]="qrCodeSize"
|
||||||
errorCorrectionLevel="H"
|
errorCorrectionLevel="H"
|
||||||
|
|||||||
@ -44,7 +44,7 @@ export class GuestCardComponent implements OnInit {
|
|||||||
.subscribe({
|
.subscribe({
|
||||||
next: (value) => {
|
next: (value) => {
|
||||||
this.customerInfo = value.customer_info;
|
this.customerInfo = value.customer_info;
|
||||||
this.cookiesService.setCookie('phone-number', this.customerInfo.phone.substr(2))
|
this.cookiesService.setCookie('phone-number', this.customerInfo?.phone?.substr(2))
|
||||||
this.getPurchases().subscribe((value) => {
|
this.getPurchases().subscribe((value) => {
|
||||||
this.purchases = this.loyaltyProgram.filterPurchases(value[this.customerInfo?.id])
|
this.purchases = this.loyaltyProgram.filterPurchases(value[this.customerInfo?.id])
|
||||||
this.lastPurchase = this.loyaltyProgram.getLastPurchase(this.purchases)
|
this.lastPurchase = this.loyaltyProgram.getLastPurchase(this.purchases)
|
||||||
|
|||||||
@ -109,6 +109,9 @@ export class LoyaltyProgramService {
|
|||||||
|
|
||||||
getBalanceAmount(loyaltyPrograms: any[]) {
|
getBalanceAmount(loyaltyPrograms: any[]) {
|
||||||
return (loyaltyPrograms || []).reduce((accumulator, currentValue) => {
|
return (loyaltyPrograms || []).reduce((accumulator, currentValue) => {
|
||||||
|
if (currentValue.wallet.name !== 'Федеральная программа лояльности') {
|
||||||
|
return accumulator
|
||||||
|
}
|
||||||
return accumulator + currentValue.balance;
|
return accumulator + currentValue.balance;
|
||||||
}, 0);
|
}, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
|||||||
import {environment} from "../../environments/environment";
|
import {environment} from "../../environments/environment";
|
||||||
import {HttpClient, HttpHeaders} from "@angular/common/http";
|
import {HttpClient, HttpHeaders} from "@angular/common/http";
|
||||||
import {CookiesService} from "./cookies.service";
|
import {CookiesService} from "./cookies.service";
|
||||||
import {Observable} from "rxjs";
|
import {Observable, of, switchMap} from "rxjs";
|
||||||
import {JsonRpcBody} from "./jsonrpc.service";
|
import {JsonRpcBody} from "./jsonrpc.service";
|
||||||
import {DeliveryType, AcceptedOrder, Product} from "../interface/data";
|
import {DeliveryType, AcceptedOrder, Product} from "../interface/data";
|
||||||
import {ActivatedRoute} from "@angular/router";
|
import {ActivatedRoute} from "@angular/router";
|
||||||
@ -43,7 +43,21 @@ export class WpJsonService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getCustomerInfo(systemId: string, token: string, url: string): Observable<any> {
|
getCustomerInfo(systemId: string, token: string, url: string): Observable<any> {
|
||||||
return this._request(`customer_info/${systemId}/${token}/`, 'GET', null, false, url)
|
return this._request(`customer_info/${systemId}/${token}/`, 'GET', null, false, url).pipe(
|
||||||
|
switchMap((response) => {
|
||||||
|
if (response.customer_info.errorCode !== 'Customer_CustomerNotFound') {
|
||||||
|
return of(response)
|
||||||
|
} else {
|
||||||
|
return this.newCustomer(systemId, token, url).pipe(
|
||||||
|
switchMap(() => this.getCustomerInfo(systemId, token, url))
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
newCustomer(systemId: string, token: string, url: string): Observable<any> {
|
||||||
|
return this._request(`new_customer/${systemId}/${token}/`, 'GET', null, false, url)
|
||||||
}
|
}
|
||||||
|
|
||||||
getTransactions(systemId: string, token: string, url: string, delta?: number): Observable<any> {
|
getTransactions(systemId: string, token: string, url: string, delta?: number): Observable<any> {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user