Merge branch 'coffee-like-test' of https://git.hlcompany.ru/git/usersite into coffee-like-test
This commit is contained in:
commit
cff512c561
@ -45,7 +45,7 @@ export class GuestCardComponent implements OnInit {
|
||||
.subscribe({
|
||||
next: (value) => {
|
||||
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.purchases = this.loyaltyProgram.filterPurchases(value[this.customerInfo?.id])
|
||||
this.lastPurchase = this.loyaltyProgram.getLastPurchase(this.purchases)
|
||||
|
||||
@ -109,6 +109,9 @@ export class LoyaltyProgramService {
|
||||
|
||||
getBalanceAmount(loyaltyPrograms: any[]) {
|
||||
return (loyaltyPrograms || []).reduce((accumulator, currentValue) => {
|
||||
if (currentValue.wallet.name !== 'Федеральная программа лояльности') {
|
||||
return accumulator
|
||||
}
|
||||
return accumulator + currentValue.balance;
|
||||
}, 0);
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
|
||||
import {environment} from "../../environments/environment";
|
||||
import {HttpClient, HttpHeaders} from "@angular/common/http";
|
||||
import {CookiesService} from "./cookies.service";
|
||||
import {Observable} from "rxjs";
|
||||
import {Observable, of, switchMap} from "rxjs";
|
||||
import {JsonRpcBody} from "./jsonrpc.service";
|
||||
import {DeliveryType, AcceptedOrder, Product} from "../interface/data";
|
||||
import {ActivatedRoute} from "@angular/router";
|
||||
@ -43,7 +43,21 @@ export class WpJsonService {
|
||||
}
|
||||
|
||||
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> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user