parent
42b46bc478
commit
76f1799b22
@ -1,4 +1,4 @@
|
|||||||
import {OrderStatus, Page, PageCode} from "./interface/data";
|
import {OrderStatus, Page, PageCode, lvlPeriod} from "./interface/data";
|
||||||
|
|
||||||
export const PageList: Page[] = [
|
export const PageList: Page[] = [
|
||||||
{
|
{
|
||||||
@ -65,3 +65,29 @@ export const orderStatuses: OrderStatus = {
|
|||||||
'Delivered': 'Выполнен',
|
'Delivered': 'Выполнен',
|
||||||
'Closed': 'Выполнен',
|
'Closed': 'Выполнен',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const lvlPeriods: lvlPeriod[] = [
|
||||||
|
{
|
||||||
|
percent: 3,
|
||||||
|
start: 0,
|
||||||
|
end: 1600,
|
||||||
|
color: '#f2c94c'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
percent: 6,
|
||||||
|
start: 1601,
|
||||||
|
end: 3600,
|
||||||
|
color: '#f2994a'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
percent: 10,
|
||||||
|
start: 3601,
|
||||||
|
end: 8600,
|
||||||
|
color: '#6fcf97'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
percent: 15,
|
||||||
|
start: 8601,
|
||||||
|
color: '#6fcf97'
|
||||||
|
},
|
||||||
|
]
|
||||||
@ -1,170 +1,179 @@
|
|||||||
|
|
||||||
|
|
||||||
export enum PageCode {
|
export enum PageCode {
|
||||||
Auth,
|
Auth,
|
||||||
Orders,
|
Orders,
|
||||||
BonusProgram,
|
BonusProgram,
|
||||||
RefSystem,
|
RefSystem,
|
||||||
UserData
|
UserData,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Page {
|
export interface Page {
|
||||||
code: PageCode;
|
code: PageCode;
|
||||||
component?: any;
|
component?: any;
|
||||||
name: string;
|
name: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
getMethod?: string;
|
getMethod?: string;
|
||||||
resName?: string;
|
resName?: string;
|
||||||
onSideBar: boolean
|
onSideBar: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserDataForm {
|
export interface UserDataForm {
|
||||||
first_name: string;
|
first_name: string;
|
||||||
birthdate: string;
|
birthdate: string;
|
||||||
gender: string;
|
gender: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BonusProgramAccount {
|
export interface BonusProgramAccount {
|
||||||
BonusProgramName: string;
|
BonusProgramName: string;
|
||||||
BonusProgramTypeID: string;
|
BonusProgramTypeID: string;
|
||||||
CardNumber: number;
|
CardNumber: number;
|
||||||
Bonuses: number;
|
Bonuses: number;
|
||||||
HoldedBonuses: number;
|
HoldedBonuses: number;
|
||||||
BonusProgramAccounts: BonusProgramAccount[];
|
BonusProgramAccounts: BonusProgramAccount[];
|
||||||
DateBonusBurn: string;
|
DateBonusBurn: string;
|
||||||
_links: any[];
|
_links: any[];
|
||||||
_embedded: any;
|
_embedded: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Purchase {
|
export interface Purchase {
|
||||||
PurchaseId?: string;
|
PurchaseId?: string;
|
||||||
CustomerId?: string;
|
CustomerId?: string;
|
||||||
PurchaseDate: string;
|
PurchaseDate: string;
|
||||||
PurchaseState?: number;
|
PurchaseState?: number;
|
||||||
CardNumber?: number;
|
CardNumber?: number;
|
||||||
Address?: string
|
Address?: string;
|
||||||
CheckSummary?: number
|
CheckSummary?: number;
|
||||||
BonusSummary?: number
|
BonusSummary?: number;
|
||||||
ID: string;
|
ID: string;
|
||||||
Transactions: Transaction[];
|
Transactions: Transaction[];
|
||||||
IsSingleTransaction?: boolean;
|
IsSingleTransaction?: boolean;
|
||||||
|
transactionCreateDate?: string;
|
||||||
|
transactionType?: 'CancelPayFromWallet' | 'PayFromWallet' | 'RefillWallet';
|
||||||
|
transactionSum: number;
|
||||||
|
orderSum?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Transaction {
|
export interface Transaction {
|
||||||
User: string;
|
User: string;
|
||||||
Purchase: string;
|
Purchase: string;
|
||||||
Date: string;
|
Date: string;
|
||||||
Value: number;
|
Value: number;
|
||||||
TransactionType: number;
|
TransactionType: number;
|
||||||
UserBonusesSnapshot: number;
|
UserBonusesSnapshot: number;
|
||||||
BonusPercent: number;
|
BonusPercent: number;
|
||||||
DateActiveBonus: string;
|
DateActiveBonus: string;
|
||||||
AccountBonus: string;
|
AccountBonus: string;
|
||||||
Bonus: string;
|
Bonus: string;
|
||||||
ID:string;
|
ID: string;
|
||||||
HasPurchase?:boolean;
|
HasPurchase?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderStatus{
|
export interface OrderStatus {
|
||||||
[key: string]: string;
|
[key: string]: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface lvlPeriod {
|
||||||
|
percent: number;
|
||||||
|
start: number;
|
||||||
|
end?: number;
|
||||||
|
color: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeliveryType {
|
export interface DeliveryType {
|
||||||
cost: number;
|
cost: number;
|
||||||
title: string;
|
title: string;
|
||||||
id: number;
|
id: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AcceptedOrder {
|
export interface AcceptedOrder {
|
||||||
id: number;
|
id: number;
|
||||||
status: string;
|
status: string;
|
||||||
currency_symbol: string;
|
currency_symbol: string;
|
||||||
|
total: number;
|
||||||
|
address: {
|
||||||
|
city: string;
|
||||||
|
street: string;
|
||||||
|
house: number;
|
||||||
|
flat: number;
|
||||||
|
};
|
||||||
|
payment_method: string;
|
||||||
|
shipping: {
|
||||||
|
name: string;
|
||||||
total: number;
|
total: number;
|
||||||
address: {
|
};
|
||||||
city: string;
|
date_created: string;
|
||||||
street: string;
|
items: OrderProduct[];
|
||||||
house: number;
|
|
||||||
flat: number;
|
|
||||||
};
|
|
||||||
payment_method: string;
|
|
||||||
shipping: {
|
|
||||||
name: string;
|
|
||||||
total: number;
|
|
||||||
};
|
|
||||||
date_created: string;
|
|
||||||
items: OrderProduct[]
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Product{
|
export interface Product {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
price: string;
|
price: string;
|
||||||
image_url: string;
|
image_url: string;
|
||||||
image_gallery: string[];
|
image_gallery: string[];
|
||||||
category_id: number;
|
category_id: number;
|
||||||
description?: string;
|
description?: string;
|
||||||
stock_status: string;
|
stock_status: string;
|
||||||
currency_symbol: string;
|
currency_symbol: string;
|
||||||
modifier_data: Modifier[];
|
modifier_data: Modifier[];
|
||||||
short_description?: string;
|
short_description?: string;
|
||||||
guid?: string;
|
guid?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Modifier{
|
export interface Modifier {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
category_type: string;
|
category_type: string;
|
||||||
minimum_options: number;
|
minimum_options: number;
|
||||||
maximum_options: number;
|
maximum_options: number;
|
||||||
global_categories: string;
|
global_categories: string;
|
||||||
required: number;
|
required: number;
|
||||||
options: Option[];
|
options: Option[];
|
||||||
allOptions?: Option[];
|
allOptions?: Option[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Option{
|
export interface Option {
|
||||||
id: number;
|
id: number;
|
||||||
name: string;
|
name: string;
|
||||||
price: string;
|
price: string;
|
||||||
prechecked: string;
|
prechecked: string;
|
||||||
active?: boolean;
|
active?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderProduct{
|
export interface OrderProduct {
|
||||||
id: number;
|
id: number;
|
||||||
amount: number;
|
amount: number;
|
||||||
name: string;
|
name: string;
|
||||||
price: number;
|
price: number;
|
||||||
modifiers: {
|
modifiers: {
|
||||||
[name: string]: OrderModifier[]
|
[name: string]: OrderModifier[];
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface OrderModifier{
|
export interface OrderModifier {
|
||||||
name: string;
|
name: string;
|
||||||
id: number;
|
id: number;
|
||||||
price: number;
|
price: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DeliveryData {
|
export interface DeliveryData {
|
||||||
paymentMethod: PaymentMethod;
|
paymentMethod: PaymentMethod;
|
||||||
deliveryDate: Date | null;
|
deliveryDate: Date | null;
|
||||||
deliveryType: DeliveryType | null;
|
deliveryType: DeliveryType | null;
|
||||||
persons: number;
|
persons: number;
|
||||||
comment: string;
|
comment: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface PaymentMethod {
|
export interface PaymentMethod {
|
||||||
type: string;
|
type: string;
|
||||||
label: string;
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserData {
|
export interface UserData {
|
||||||
first_name: string | null;
|
first_name: string | null;
|
||||||
last_name: string | null;
|
last_name: string | null;
|
||||||
street: string | null;
|
street: string | null;
|
||||||
house: string | null;
|
house: string | null;
|
||||||
flat: string | null;
|
flat: string | null;
|
||||||
city: string;
|
city: string;
|
||||||
phone: string | null;
|
phone: string | null;
|
||||||
}
|
}
|
||||||
@ -1,162 +1,198 @@
|
|||||||
<app-navbar title="Карта гостя" (backEvent)="logout()"></app-navbar>
|
<app-navbar title="Карта гостя" (backEvent)="logout()"></app-navbar>
|
||||||
|
|
||||||
<ng-container
|
<div class="guest-card">
|
||||||
*ngTemplateOutlet="appTpl; context: { user: customerInfo | async }"
|
<div class="guest-card__qr" (click)="qrCodeClick()">
|
||||||
></ng-container>
|
<ng-container *ngIf="customerInfo">
|
||||||
|
|
||||||
<ng-template #appTpl let-user="user">
|
|
||||||
<div class="guest-card">
|
|
||||||
<div class="guest-card__qr" (click)="qrCodeClick()">
|
|
||||||
<qr-code
|
<qr-code
|
||||||
*ngIf="user; else spinner"
|
[value]="customerInfo?.phone.substr(2) || 'Данные не найдены'"
|
||||||
[value]="user?.customer_info?.phone.substr(2) || 'Данные не найдены'"
|
|
||||||
[margin]="0"
|
[margin]="0"
|
||||||
[size]="qrCodeSize"
|
[size]="qrCodeSize"
|
||||||
errorCorrectionLevel="M"
|
errorCorrectionLevel="M"
|
||||||
></qr-code>
|
></qr-code>
|
||||||
</div>
|
</ng-container>
|
||||||
<div class="guest-card__user-description">
|
<ng-container *ngIf="!customerInfo">
|
||||||
Текущий баланс бонусов:
|
<ng-container
|
||||||
<span *ngIf="user">
|
*ngTemplateOutlet="spinner; context: { $implicit: 85 }"
|
||||||
{{
|
></ng-container>
|
||||||
getBalanceAmount(user?.customer_info?.walletBalances)
|
</ng-container>
|
||||||
}}
|
</div>
|
||||||
бонусов</span
|
<div class="guest-card__user-description">
|
||||||
>
|
Текущий баланс бонусов:
|
||||||
</div>
|
<span *ngIf="customerInfo">
|
||||||
<app-accordion header="Условия начисления бонусов">
|
{{ getBalanceAmount(customerInfo?.walletBalances) }}
|
||||||
<p>
|
бонусов</span
|
||||||
Расчет начисления бонусов - 10% от суммы покупок за период с
|
|
||||||
11.01.2023г. по 31.03.2023 г.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
За период с 11.01.2023г. по 31.03.2023 г. сумма ваших покупок составила
|
|
||||||
3700 руб.
|
|
||||||
</p>
|
|
||||||
<p>Начисляемый бонус 10% от суммы покупок</p>
|
|
||||||
</app-accordion>
|
|
||||||
<app-accordion header="Условия «оплаты» покупки бонусами">
|
|
||||||
<p>
|
|
||||||
Участник может использовать Бонусы для «оплаты» до 100% стоимости любой
|
|
||||||
покупки.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Списание Бонусов происходит из расчета 1:1 (один Бонус дает скидку 1
|
|
||||||
российский рубль / 1 тенге / 1 белорусский рубль. Скидка,
|
|
||||||
предоставляемая Участнику при списании Бонусов, уменьшает цену товаров в
|
|
||||||
заказе в соответствии с условиями ПЛ.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Для списания Бонусов Участник должен попросить об этом в кофе-баре сети
|
|
||||||
«COFFEE LIKE» кассира до момента пробития фискального чека, после чего
|
|
||||||
им будет проверена возможность списания Бонусов.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
Для всех Участников возможно списание без использования мобильного
|
|
||||||
приложения.
|
|
||||||
</p>
|
|
||||||
<p>Полученные Бонусы не подлежат обмену на денежные средства.</p>
|
|
||||||
</app-accordion>
|
|
||||||
<app-accordion header="Особые условия">
|
|
||||||
<p>
|
|
||||||
Начисленные на счет бонусы сгорают по прошествии 90 дней с момента
|
|
||||||
совершения последней покупки с начислением или списанием бонусов.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
Возврат покупки, за которую бонусы были начислены:
|
|
||||||
<li>
|
|
||||||
В случае, если бонусов на счету достаточно для списания, бонусы
|
|
||||||
списываются в полном ранее начисленном за возвращаемый товар объеме.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
В случае, если бонусов на счету недостаточно, формируется минусовой
|
|
||||||
баланс.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
Возврат покупки, которая была оплачена бонусами:
|
|
||||||
<li>
|
|
||||||
В случае предъявления Участником кассового или товарного чека, сумма
|
|
||||||
бонусов, списанная для оплаты возвращаемого товара, зачисляется на
|
|
||||||
счет участника.
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
В случае возврата товара с применением оплаты бонусами, клиенту
|
|
||||||
возвращается денежная сумма в размере, внесенном Участником в оплату
|
|
||||||
товара при покупке, за вычетом суммы, оплаченной бонусами.
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</app-accordion>
|
|
||||||
|
|
||||||
<div class="guest-card__purchases-description">
|
|
||||||
Сумма ваших покупок за период с 01.04.2023г. - <span>1200 руб.</span>
|
|
||||||
</div>
|
|
||||||
<app-accordion header="Узнать % начисляемых бонусов">
|
|
||||||
<p>
|
|
||||||
Начисление Бонусных баллов происходит по дифференцированной шкале в
|
|
||||||
зависимости от уровня:
|
|
||||||
</p>
|
|
||||||
|
|
||||||
<ul>
|
|
||||||
<span style="color: #f2c94c">Уровень 1</span>
|
|
||||||
<li>Сумма покупок за предыдущий период 0-1600 руб.</li>
|
|
||||||
<li>Начисляемый бонус 3% от суммы покупки</li>
|
|
||||||
</ul>
|
|
||||||
<br />
|
|
||||||
<ul>
|
|
||||||
<span style="color: #f2994a">Уровень 2</span>
|
|
||||||
<li>Сумма покупок за предыдущий период 1601-3600 руб.</li>
|
|
||||||
<li>Начисляемый бонус 6% от суммы покупки</li>
|
|
||||||
</ul>
|
|
||||||
<br />
|
|
||||||
<ul>
|
|
||||||
<span style="color: #6fcf97">Уровень 3</span>
|
|
||||||
<li>Сумма покупок за предыдущий период 3601-8600 руб.</li>
|
|
||||||
<li>Начисляемый бонус 10% от суммы покупки</li>
|
|
||||||
</ul>
|
|
||||||
<br />
|
|
||||||
<ul>
|
|
||||||
<span style="color: #6fcf97">Уровень 4</span>
|
|
||||||
<li>Сумма покупок за предыдущий период — от 8601 руб.</li>
|
|
||||||
<li>Начисляемый бонус, в % от суммы покупки - 15%</li>
|
|
||||||
</ul>
|
|
||||||
</app-accordion>
|
|
||||||
|
|
||||||
<div class="guest-card__level-info">
|
|
||||||
<h2>
|
|
||||||
До следующего уровня за период с 01.04.2023 по 30.06.2023г осталось
|
|
||||||
совершить покупки на 401 рублей
|
|
||||||
</h2>
|
|
||||||
<input
|
|
||||||
type="range"
|
|
||||||
[(ngModel)]="discountLevel"
|
|
||||||
[min]="3"
|
|
||||||
[max]="6"
|
|
||||||
[step]="0.1"
|
|
||||||
[ngStyle]="{
|
|
||||||
'background-size': ((discountLevel - 3) / (6 - 3)) * 100 + '% 100%'
|
|
||||||
}"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<p class="show-more">Узнать условия начисления бонусов</p>
|
|
||||||
</div>
|
|
||||||
<hr />
|
|
||||||
<app-last-order></app-last-order>
|
|
||||||
<hr />
|
|
||||||
<app-invite-friends></app-invite-friends>
|
|
||||||
<hr />
|
|
||||||
<div class="guest-card__download-app">
|
|
||||||
<img src="/assets/download-app.svg" alt="Скачай приложение" />
|
|
||||||
</div>
|
|
||||||
<a class="guest-card__loyalty-program" routerLink="loyalty-program"
|
|
||||||
>Подробнее о правилах <br />
|
|
||||||
Программы лояльности</a
|
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</ng-template>
|
<span id="bonuses-condition"></span>
|
||||||
|
<app-accordion header="Условия начисления бонусов">
|
||||||
|
<p>
|
||||||
|
Расчет начисления бонусов - 10% от суммы покупок за период с 11.01.2023г.
|
||||||
|
по 31.03.2023 г.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
За период с 11.01.2023г. по 31.03.2023 г. сумма ваших покупок составила
|
||||||
|
3700 руб.
|
||||||
|
</p>
|
||||||
|
<p>Начисляемый бонус 10% от суммы покупок</p>
|
||||||
|
</app-accordion>
|
||||||
|
<app-accordion header="Условия «оплаты» покупки бонусами">
|
||||||
|
<p>
|
||||||
|
Участник может использовать Бонусы для «оплаты» до 100% стоимости любой
|
||||||
|
покупки.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Списание Бонусов происходит из расчета 1:1 (один Бонус дает скидку 1
|
||||||
|
российский рубль / 1 тенге / 1 белорусский рубль. Скидка, предоставляемая
|
||||||
|
Участнику при списании Бонусов, уменьшает цену товаров в заказе в
|
||||||
|
соответствии с условиями ПЛ.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Для списания Бонусов Участник должен попросить об этом в кофе-баре сети
|
||||||
|
«COFFEE LIKE» кассира до момента пробития фискального чека, после чего им
|
||||||
|
будет проверена возможность списания Бонусов.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
Для всех Участников возможно списание без использования мобильного
|
||||||
|
приложения.
|
||||||
|
</p>
|
||||||
|
<p>Полученные Бонусы не подлежат обмену на денежные средства.</p>
|
||||||
|
</app-accordion>
|
||||||
|
<app-accordion header="Особые условия">
|
||||||
|
<p>
|
||||||
|
Начисленные на счет бонусы сгорают по прошествии 90 дней с момента
|
||||||
|
совершения последней покупки с начислением или списанием бонусов.
|
||||||
|
</p>
|
||||||
|
|
||||||
<ng-template #spinner>
|
<ul>
|
||||||
<mat-spinner></mat-spinner>
|
Возврат покупки, за которую бонусы были начислены:
|
||||||
|
<li>
|
||||||
|
В случае, если бонусов на счету достаточно для списания, бонусы
|
||||||
|
списываются в полном ранее начисленном за возвращаемый товар объеме.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
В случае, если бонусов на счету недостаточно, формируется минусовой
|
||||||
|
баланс.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
Возврат покупки, которая была оплачена бонусами:
|
||||||
|
<li>
|
||||||
|
В случае предъявления Участником кассового или товарного чека, сумма
|
||||||
|
бонусов, списанная для оплаты возвращаемого товара, зачисляется на счет
|
||||||
|
участника.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
В случае возврата товара с применением оплаты бонусами, клиенту
|
||||||
|
возвращается денежная сумма в размере, внесенном Участником в оплату
|
||||||
|
товара при покупке, за вычетом суммы, оплаченной бонусами.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</app-accordion>
|
||||||
|
|
||||||
|
<div
|
||||||
|
class="guest-card__purchases-description"
|
||||||
|
[ngStyle]="{
|
||||||
|
display: purchaseData.$loading ? 'grid' : 'block'
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
Сумма ваших покупок за период с
|
||||||
|
{{ purchaseData.currentPeriod[0].format("DD.MM.yyyyг.") }} -
|
||||||
|
<span *ngIf="!purchaseData.$loading"
|
||||||
|
>{{ purchaseData.currentAmount }} руб.</span
|
||||||
|
>
|
||||||
|
<ng-container *ngIf="purchaseData.$loading">
|
||||||
|
<ng-container
|
||||||
|
*ngTemplateOutlet="spinner; context: { $implicit: 24 }"
|
||||||
|
></ng-container>
|
||||||
|
</ng-container>
|
||||||
|
</div>
|
||||||
|
<app-accordion header="Узнать % начисляемых бонусов">
|
||||||
|
<p>
|
||||||
|
Начисление Бонусных баллов происходит по дифференцированной шкале в
|
||||||
|
зависимости от уровня:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<ng-container
|
||||||
|
*ngFor="let item of lvlPeriods; let index = index; let last = last"
|
||||||
|
>
|
||||||
|
<ng-container *ngIf="!last">
|
||||||
|
<ul>
|
||||||
|
<span [style]="{ color: item.color }">Уровень {{ index + 1 }}</span>
|
||||||
|
<li>
|
||||||
|
Сумма покупок за предыдущий период {{ item.start }}-{{ item.end }}
|
||||||
|
руб.
|
||||||
|
</li>
|
||||||
|
<li>Начисляемый бонус {{ item.percent }}% от суммы покупки</li>
|
||||||
|
</ul>
|
||||||
|
<br />
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="last">
|
||||||
|
<ul>
|
||||||
|
<span [style]="{ color: item.color }">Уровень {{ index + 1 }}</span>
|
||||||
|
<li>Сумма покупок за предыдущий период — от {{ item.start }} руб.</li>
|
||||||
|
<li>Начисляемый бонус, в % от суммы покупки - {{ item.percent }}%</li>
|
||||||
|
</ul>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
|
</app-accordion>
|
||||||
|
|
||||||
|
<div class="guest-card__level-info">
|
||||||
|
<ng-container *ngIf="!purchaseData.$loading">
|
||||||
|
<ng-container *ngIf="currentLvlPeriod.end">
|
||||||
|
<h2>
|
||||||
|
До следующего уровня за период с
|
||||||
|
{{ purchaseData.currentPeriod[0].format("DD.MM.yyyyг") }} по
|
||||||
|
{{ purchaseData.currentPeriod[1].format("DD.MM.yyyyг") }}
|
||||||
|
осталось совершить покупки на {{ currentLvlPeriod.end - (purchaseData.currentAmount || 0) + 1 }} рублей
|
||||||
|
</h2>
|
||||||
|
<input
|
||||||
|
type="range"
|
||||||
|
[value]="purchaseData.currentAmount"
|
||||||
|
[min]="currentLvlPeriod.start"
|
||||||
|
[max]="currentLvlPeriod.end"
|
||||||
|
[step]="0.01"
|
||||||
|
disabled="true"
|
||||||
|
[ngStyle]="{
|
||||||
|
'background-size': ((purchaseData.currentAmount! - currentLvlPeriod.start) / (currentLvlPeriod.end - currentLvlPeriod.start + 1)) * 100 + '% 100%'
|
||||||
|
}"
|
||||||
|
/>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="!currentLvlPeriod.end">
|
||||||
|
<h2>
|
||||||
|
У Вас последний уровень бонусной программы. Процент начисляемых бонусов: {{currentLvlPeriod.percent}}%
|
||||||
|
</h2>
|
||||||
|
</ng-container>
|
||||||
|
</ng-container>
|
||||||
|
<ng-container *ngIf="purchaseData.$loading">
|
||||||
|
<ng-container
|
||||||
|
*ngTemplateOutlet="spinner; context: { $implicit: 48 }"
|
||||||
|
></ng-container>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<p class="show-more">
|
||||||
|
<a href="#bonuses-condition">
|
||||||
|
Узнать условия начисления бонусов
|
||||||
|
</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<hr />
|
||||||
|
<app-last-order
|
||||||
|
[lastOrder]="lastPurchase"
|
||||||
|
[loading]="purchaseData.$loading"
|
||||||
|
></app-last-order>
|
||||||
|
<hr />
|
||||||
|
<app-invite-friends></app-invite-friends>
|
||||||
|
<hr />
|
||||||
|
<div class="guest-card__download-app">
|
||||||
|
<img src="/assets/download-app.svg" alt="Скачай приложение" />
|
||||||
|
</div>
|
||||||
|
<a class="guest-card__loyalty-program" routerLink="loyalty-program"
|
||||||
|
>Подробнее о правилах <br />
|
||||||
|
Программы лояльности</a
|
||||||
|
>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ng-template #spinner let-diameter>
|
||||||
|
<mat-spinner [strokeWidth]="3" [diameter]="diameter"></mat-spinner>
|
||||||
</ng-template>
|
</ng-template>
|
||||||
|
|||||||
@ -62,6 +62,7 @@
|
|||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
line-height: 19px;
|
line-height: 19px;
|
||||||
letter-spacing: -0.5px;
|
letter-spacing: -0.5px;
|
||||||
|
grid-template-columns: calc(100% - 24px) 24px;
|
||||||
|
|
||||||
span {
|
span {
|
||||||
color: #219653;
|
color: #219653;
|
||||||
@ -70,6 +71,9 @@
|
|||||||
|
|
||||||
&__level-info {
|
&__level-info {
|
||||||
padding: 36px;
|
padding: 36px;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
align-items: center;
|
||||||
|
|
||||||
h2 {
|
h2 {
|
||||||
font-style: normal;
|
font-style: normal;
|
||||||
@ -152,7 +156,10 @@
|
|||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: #28af49;
|
a {
|
||||||
|
text-decoration: none;
|
||||||
|
color: #28af49;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,9 +7,21 @@ import { CookiesService } from 'src/app/services/cookies.service';
|
|||||||
import { WpJsonService } from 'src/app/services/wp-json.service';
|
import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||||
import { environment } from 'src/environments/environment';
|
import { environment } from 'src/environments/environment';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
|
import { Purchase, lvlPeriod } from 'src/app/interface/data';
|
||||||
|
import { lvlPeriods } from 'src/app/app.constants';
|
||||||
|
|
||||||
interface Moment extends moment.Moment {}
|
interface Moment extends moment.Moment {}
|
||||||
|
|
||||||
|
export interface IPurchaseData {
|
||||||
|
currentPeriod: Moment[];
|
||||||
|
lastPeriod: Moment[];
|
||||||
|
lastPurchases: Purchase[];
|
||||||
|
currentPurchases: Purchase[];
|
||||||
|
lastAmount?: number;
|
||||||
|
currentAmount?: number;
|
||||||
|
$loading: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-guest-card',
|
selector: 'app-guest-card',
|
||||||
templateUrl: './guest-card.component.html',
|
templateUrl: './guest-card.component.html',
|
||||||
@ -18,10 +30,35 @@ interface Moment extends moment.Moment {}
|
|||||||
export class GuestCardComponent implements OnInit {
|
export class GuestCardComponent implements OnInit {
|
||||||
public qrCodeSize: number = 85;
|
public qrCodeSize: number = 85;
|
||||||
private isQrCodeClicked: boolean = false;
|
private isQrCodeClicked: boolean = false;
|
||||||
public customerInfo!: Observable<any>;
|
public customerInfo!: any;
|
||||||
public purchases!: Observable<any>;
|
public purchases!: Purchase[];
|
||||||
|
public lastPurchase!: Purchase;
|
||||||
|
public purchaseData: IPurchaseData = {
|
||||||
|
currentPeriod: [],
|
||||||
|
lastPeriod: [],
|
||||||
|
lastPurchases: [],
|
||||||
|
currentPurchases: [],
|
||||||
|
$loading: true,
|
||||||
|
get currentAmount():number {
|
||||||
|
// const amount = this.currentPurchases.reduce((accumulator, currentValue) => {
|
||||||
|
// if (currentValue.transactionType !== 'PayFromWallet') return 0;
|
||||||
|
// return accumulator + currentValue.transactionSum;
|
||||||
|
// }, 0);
|
||||||
|
// return amount * -1
|
||||||
|
return 8601
|
||||||
|
},
|
||||||
|
get lastAmount():number {
|
||||||
|
const amount = this.lastPurchases.reduce((accumulator, currentValue) => {
|
||||||
|
if (currentValue.transactionType !== 'PayFromWallet') return 0;
|
||||||
|
return accumulator + currentValue.transactionSum;
|
||||||
|
}, 0);
|
||||||
|
return amount * -1
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
public discountLevel: number = 4.2;
|
public discountLevel: number = 4.2;
|
||||||
|
public lvlPeriods: lvlPeriod[] = lvlPeriods;
|
||||||
|
public currentLvlPeriod!: lvlPeriod;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private _bottomSheet: MatBottomSheet,
|
private _bottomSheet: MatBottomSheet,
|
||||||
@ -32,13 +69,44 @@ export class GuestCardComponent implements OnInit {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
const token = this.cookiesService.getItem('token');
|
const token = this.cookiesService.getItem('token');
|
||||||
this.customerInfo = this.wpJsonService.getCustomerInfo(
|
this.getCurrentQuarterOfYear();
|
||||||
environment.systemId,
|
this.wpJsonService
|
||||||
token || '',
|
.getCustomerInfo(
|
||||||
environment.icardProxy
|
environment.systemId,
|
||||||
);
|
token || '',
|
||||||
this.purchases = this.getPurchases();
|
environment.icardProxy
|
||||||
this.purchases.subscribe((value) => console.log(value));
|
)
|
||||||
|
.subscribe({
|
||||||
|
next: (value) => {
|
||||||
|
this.customerInfo = value.customer_info;
|
||||||
|
this.getPurchases().subscribe((value) => {
|
||||||
|
this.purchases = value[this.customerInfo?.id].filter(
|
||||||
|
(purchase: Purchase) =>
|
||||||
|
[
|
||||||
|
'PayFromWallet',
|
||||||
|
'CancelPayFromWallet',
|
||||||
|
'RefillWallet',
|
||||||
|
].includes(purchase.transactionType || '')
|
||||||
|
);
|
||||||
|
this.lastPurchase = value[this.customerInfo?.id].filter(
|
||||||
|
(purchase: Purchase) =>
|
||||||
|
[
|
||||||
|
'PayFromWallet',
|
||||||
|
].includes(purchase.transactionType || '')
|
||||||
|
)[0]
|
||||||
|
|
||||||
|
this.purchaseData.lastPurchases = this.purchases.filter((value: Purchase) => {
|
||||||
|
return moment(value.transactionCreateDate).isBetween(this.purchaseData.lastPeriod[0], this.purchaseData.lastPeriod[1])
|
||||||
|
})
|
||||||
|
this.purchaseData.currentPurchases = this.purchases.filter((value: Purchase) => {
|
||||||
|
return moment(value.transactionCreateDate).isBetween(this.purchaseData.currentPeriod[0], this.purchaseData.currentPeriod[1])
|
||||||
|
})
|
||||||
|
const currentAmount = this.purchaseData.currentAmount || 0
|
||||||
|
this.currentLvlPeriod = this.lvlPeriods.find((item) => item.start <= currentAmount && currentAmount <= (item.end || Infinity))!
|
||||||
|
this.purchaseData.$loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
qrCodeClick() {
|
qrCodeClick() {
|
||||||
@ -63,26 +131,50 @@ export class GuestCardComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getPurchases(
|
getPurchases(
|
||||||
start: Date | Moment = moment().startOf('month'),
|
start: Date | Moment = moment().subtract(1, 'months').startOf('month'),
|
||||||
end: Date | Moment = moment()
|
end: Date | Moment = moment()
|
||||||
): Observable<any> {
|
): Observable<any> {
|
||||||
const token = this.cookiesService.getItem('token');
|
const token = this.cookiesService.getItem('token');
|
||||||
const delta = moment(end).diff(moment(start), 'days');
|
const delta = moment(end).diff(moment(start), 'days');
|
||||||
return this.wpJsonService.getTransactionsInfo(
|
return this.wpJsonService.getTransactions(
|
||||||
environment.systemId,
|
environment.systemId,
|
||||||
token ?? '',
|
token ?? '',
|
||||||
environment.icardProxy
|
environment.icardProxy
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
getBalanceAmount(loyaltyPrograms: any[]) {
|
getCurrentQuarterOfYear() {
|
||||||
console.log(loyaltyPrograms);
|
const quarters = [
|
||||||
|
[
|
||||||
|
moment().subtract(1, 'years').endOf('year').subtract(3, 'months'),
|
||||||
|
moment().subtract(1, 'years').endOf('year'),
|
||||||
|
],
|
||||||
|
[moment().startOf('year'), moment().startOf('year').add(3, 'months')],
|
||||||
|
[
|
||||||
|
moment().startOf('year').add(3, 'months'),
|
||||||
|
moment().startOf('year').add(6, 'months'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
moment().startOf('year').add(6, 'months'),
|
||||||
|
moment().startOf('year').add(9, 'months'),
|
||||||
|
],
|
||||||
|
[
|
||||||
|
moment().startOf('year').add(9, 'months'),
|
||||||
|
moment().startOf('year').add(12, 'months'),
|
||||||
|
],
|
||||||
|
];
|
||||||
|
|
||||||
return loyaltyPrograms.reduce(
|
for (let i = 0; i < 4; i++) {
|
||||||
(accumulator, currentValue) => {
|
if (moment().isBetween(quarters[i][0], quarters[i][1])) {
|
||||||
return accumulator + currentValue.balance
|
this.purchaseData.lastPeriod = quarters[i - 1];
|
||||||
},
|
this.purchaseData.currentPeriod = quarters[i];
|
||||||
0
|
}
|
||||||
);
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
getBalanceAmount(loyaltyPrograms: any[]) {
|
||||||
|
return loyaltyPrograms.reduce((accumulator, currentValue) => {
|
||||||
|
return accumulator + currentValue.balance;
|
||||||
|
}, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user