dev #13014
Переделал 'Ваша карта лояльности' и 'Ваши чеки' на icard-proxy
This commit is contained in:
parent
352986de93
commit
5a5acb53fd
@ -20,6 +20,7 @@
|
||||
"builder": "@angular-devkit/build-angular:browser",
|
||||
"options": {
|
||||
"outputPath": "/var/www/html/lk.crm4retail.ru/sakura",
|
||||
"deleteOutputPath": false,
|
||||
"baseHref": "/",
|
||||
"index": "src/index.html",
|
||||
"main": "src/main.ts",
|
||||
@ -30,11 +31,10 @@
|
||||
"src/favicon.ico",
|
||||
"src/assets",
|
||||
"src/manifest.webmanifest",
|
||||
"src/firebase-messaging-sw.js",
|
||||
"src/static"
|
||||
"src/firebase-messaging-sw.js"
|
||||
],
|
||||
"styles": [
|
||||
"node_modules/primeng/resources/themes/bootstrap4-light-blue/theme.css",
|
||||
"node_modules/primeng/resources/themes/saga-blue/theme.css",
|
||||
"node_modules/primeicons/primeicons.css",
|
||||
"node_modules/primeng/resources/primeng.min.css",
|
||||
"node_modules/ngx-sharebuttons/themes/modern.scss",
|
||||
@ -85,7 +85,8 @@
|
||||
"browserTarget": "sakura:build:production"
|
||||
},
|
||||
"development": {
|
||||
"browserTarget": "sakura:build:development"
|
||||
"browserTarget": "sakura:build:development",
|
||||
"proxyConfig": "proxy.confi.json"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
|
||||
@ -36,20 +36,20 @@ export const PageListWithBonus: Page[] = [
|
||||
resName: 'orders',
|
||||
onSideBar: true,
|
||||
},
|
||||
{
|
||||
code: PageCode.UserData,
|
||||
name: 'Заполнить анкету',
|
||||
description: '',
|
||||
resName: 'user-data',
|
||||
onSideBar: true
|
||||
},
|
||||
{
|
||||
code: PageCode.RefSystem,
|
||||
name: 'Пригласить друга',
|
||||
description: '',
|
||||
resName: 'ref-system',
|
||||
onSideBar: true,
|
||||
},
|
||||
// {
|
||||
// code: PageCode.UserData,
|
||||
// name: 'Заполнить анкету',
|
||||
// description: '',
|
||||
// resName: 'user-data',
|
||||
// onSideBar: true
|
||||
// },
|
||||
// {
|
||||
// code: PageCode.RefSystem,
|
||||
// name: 'Пригласить друга',
|
||||
// description: '',
|
||||
// resName: 'ref-system',
|
||||
// onSideBar: true,
|
||||
// },
|
||||
];
|
||||
|
||||
export const PageListMain: Page[] = [
|
||||
|
||||
@ -32,29 +32,32 @@ export interface UserDataForm {
|
||||
}
|
||||
|
||||
export interface BonusProgramAccount {
|
||||
BonusProgramName: string;
|
||||
BonusProgramTypeID: string;
|
||||
// BonusProgramName: string;
|
||||
// BonusProgramTypeID: string;
|
||||
CardNumber: number;
|
||||
Bonuses: number;
|
||||
HoldedBonuses: number;
|
||||
BonusProgramAccounts: BonusProgramAccount[];
|
||||
DateBonusBurn: string;
|
||||
_links: any[];
|
||||
_embedded: any;
|
||||
// HoldedBonuses: number;
|
||||
// BonusProgramAccounts: BonusProgramAccount[];
|
||||
// DateBonusBurn: string;
|
||||
// _links: any[];
|
||||
// _embedded: any;
|
||||
}
|
||||
|
||||
export interface Purchase {
|
||||
PurchaseId?: string;
|
||||
CustomerId?: string;
|
||||
PurchaseDate: string;
|
||||
PurchaseState?: number;
|
||||
CardNumber?: number;
|
||||
Address?: string
|
||||
CheckSummary?: number
|
||||
BonusSummary?: number
|
||||
ID: string;
|
||||
Transactions: Transaction[];
|
||||
IsSingleTransaction?: boolean;
|
||||
// PurchaseId?: string;
|
||||
// CustomerId?: string;
|
||||
// PurchaseDate: string;
|
||||
// PurchaseState?: number;
|
||||
// CardNumber?: number;
|
||||
// Address?: string
|
||||
// CheckSummary?: number
|
||||
// BonusSummary?: number
|
||||
// ID: string;
|
||||
// Transactions: Transaction[];
|
||||
// IsSingleTransaction?: boolean;
|
||||
transactionCreateDate: string;
|
||||
orderSum: number;
|
||||
transactionSum: number;
|
||||
}
|
||||
|
||||
export interface Transaction {
|
||||
|
||||
@ -32,7 +32,7 @@
|
||||
<app-auth [handleHttpError]="handleHttpErrorFunc" (phoneConfirmed)="phoneConfirmed()"></app-auth>
|
||||
</ng-container>
|
||||
<ng-container *ngSwitchCase="PageCode.Orders">
|
||||
<app-orders></app-orders>
|
||||
<app-orders (deauthorization)="changePage(pageList[0])"></app-orders>
|
||||
</ng-container>
|
||||
<ng-container *ngSwitchCase="PageCode.BonusProgram">
|
||||
<app-bonus-program (deauthorization)="changePage(pageList[0])"></app-bonus-program>
|
||||
|
||||
@ -83,11 +83,11 @@ export class AuthComponent {
|
||||
next: (result) => {
|
||||
if (result.code === 0) {
|
||||
this.cookiesService.setCookie('token', result?.data?.token);
|
||||
this.router.navigate(['/auth'], {
|
||||
queryParams: {
|
||||
token: result?.data?.token
|
||||
},
|
||||
});
|
||||
// this.router.navigate(['/auth'], {
|
||||
// queryParams: {
|
||||
// token: result?.data?.token
|
||||
// },
|
||||
// });
|
||||
this.phoneConfirmed.emit(null);
|
||||
} else {
|
||||
this.errorConfirmCode = true;
|
||||
|
||||
@ -10,6 +10,7 @@ import { AppleWalletService } from 'src/app/services/apple-wallet.service';
|
||||
import { CookiesService } from 'src/app/services/cookies.service';
|
||||
import { DOCUMENT } from '@angular/common';
|
||||
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||||
import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-bonus-program',
|
||||
@ -34,94 +35,47 @@ export class BonusProgramComponent implements OnInit {
|
||||
private cookiesService: CookiesService,
|
||||
@Inject(DOCUMENT) private document: Document,
|
||||
private http: HttpClient,
|
||||
private wpJsonService: WpJsonService,
|
||||
) { }
|
||||
|
||||
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getAccountData();
|
||||
this.getTypeDevice()
|
||||
this.getTypeDevice();
|
||||
}
|
||||
|
||||
getTypeDevice() {
|
||||
const userAgent = window.navigator.userAgent.toLowerCase()
|
||||
const ios = /iphone|ipod|ipad/.test( userAgent );
|
||||
this.deviceType = ios ? 'ios' : 'android'
|
||||
}
|
||||
|
||||
async getAccountData(): Promise<void>{
|
||||
getAccountData() {
|
||||
const token = this.cookiesService.getItem('token')
|
||||
if (!token) {
|
||||
this.cookiesService.deleteCookie('token')
|
||||
this.deauthorization.emit(true)
|
||||
return
|
||||
}
|
||||
this.loadingBonuses = true;
|
||||
|
||||
this.jsonrpc.rpc({
|
||||
method: 'getAdditionalInfo',
|
||||
params: []
|
||||
}, RpcService.authService, true).subscribe({
|
||||
this.wpJsonService.getCustomerInfo(environment.systemId, token, environment.icardProxy).subscribe({
|
||||
next: (res) => {
|
||||
if (res.code == 334) {
|
||||
this.cookiesService.deleteCookie('token')
|
||||
this.deauthorization.emit(true)
|
||||
return
|
||||
this.userName = res.customer_info.name
|
||||
this.accountData = {
|
||||
CardNumber: res.customer_info.cards[0].Number,
|
||||
Bonuses: res.customer_info.walletBalances[0].balance
|
||||
}
|
||||
this.userName = res.data.first_name
|
||||
barcode("#barcode")
|
||||
.options({ font: "OCR-B" }) // Will affect all barcodes
|
||||
.EAN13(`${this.accountData.CardNumber}`.padStart(12, "0"), { fontSize: 18, textMargin: 0 })
|
||||
.render();
|
||||
this.loadingBonuses = false;
|
||||
},
|
||||
error: (err) => {
|
||||
console.error('Error: ', err)
|
||||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
this.accountData = (await lastValueFrom(
|
||||
this.jsonrpc.rpc({
|
||||
method: 'GetAccounts',
|
||||
params: []
|
||||
},
|
||||
RpcService.bonusService
|
||||
)))['Cards'][0];
|
||||
this.loadingBonuses = false;
|
||||
|
||||
barcode("#barcode")
|
||||
.options({font: "OCR-B"}) // Will affect all barcodes
|
||||
.EAN13(`${this.accountData.CardNumber}`.padStart(12, "0"), {fontSize: 18, textMargin: 0})
|
||||
.render();
|
||||
const transactions: Transaction[] = (await lastValueFrom(
|
||||
this.jsonrpc.rpc(
|
||||
{
|
||||
method: 'GetAccountTransactions',
|
||||
params: []
|
||||
},
|
||||
RpcService.bonusService
|
||||
)))['Transactions'];
|
||||
|
||||
const purchases: Purchase[] = (await lastValueFrom(
|
||||
this.jsonrpc.rpc(
|
||||
{
|
||||
method: 'GetAccountPurchase',
|
||||
params: []
|
||||
},
|
||||
RpcService.bonusService
|
||||
)))['Purchases'];
|
||||
|
||||
this.purchases = purchases.map<Purchase>((purchase) => {
|
||||
const id = purchase.ID.slice(0,36).toLowerCase();
|
||||
purchase.Transactions = transactions.filter((transaction) => {
|
||||
const same = transaction.Purchase === id;
|
||||
transaction.HasPurchase = same;
|
||||
return same;
|
||||
});
|
||||
return purchase;
|
||||
});
|
||||
transactions.forEach((transaction) => {
|
||||
if(!transaction.HasPurchase){
|
||||
this.purchases.push({
|
||||
ID: transaction.ID,
|
||||
PurchaseDate: transaction.Date,
|
||||
Transactions: [transaction],
|
||||
IsSingleTransaction: true,
|
||||
})
|
||||
}
|
||||
});
|
||||
this.purchases = this.purchases.sort((a,b) => {
|
||||
return moment(a.PurchaseDate).date() - moment(b.PurchaseDate).date();
|
||||
});
|
||||
getTypeDevice() {
|
||||
const userAgent = window.navigator.userAgent.toLowerCase()
|
||||
const ios = /iphone|ipod|ipad/.test(userAgent);
|
||||
this.deviceType = ios ? 'ios' : 'android'
|
||||
}
|
||||
|
||||
|
||||
@ -146,11 +100,11 @@ export class BonusProgramComponent implements OnInit {
|
||||
},
|
||||
error: (err) => {
|
||||
console.log('Error: ', err);
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -9,11 +9,11 @@
|
||||
>
|
||||
<span class="nobr">Дата</span>
|
||||
</th>
|
||||
<th
|
||||
<!-- <th
|
||||
class="woocommerce-orders-table__header woocommerce-orders-table__header-order-status"
|
||||
>
|
||||
<span class="nobr">Место покупки</span>
|
||||
</th>
|
||||
</th> -->
|
||||
<th
|
||||
class="woocommerce-orders-table__header woocommerce-orders-table__header-order-total"
|
||||
>
|
||||
@ -35,33 +35,33 @@
|
||||
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-date"
|
||||
data-title="Дата"
|
||||
>
|
||||
<time [dateTime]="purchase.PurchaseDate">{{
|
||||
moment(purchase.PurchaseDate).format("DD.MM.YYYY")
|
||||
<time [dateTime]="purchase.transactionCreateDate">{{
|
||||
moment(purchase.transactionCreateDate).format("DD.MM.YYYY")
|
||||
}}</time>
|
||||
</td>
|
||||
<td
|
||||
<!-- <td
|
||||
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-status"
|
||||
data-title="Место покупки"
|
||||
>
|
||||
{{ purchase.Address }}
|
||||
</td>
|
||||
</td> -->
|
||||
<td
|
||||
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-total"
|
||||
data-title="Сумма чека"
|
||||
>
|
||||
<span class="woocommerce-Price-amount amount">
|
||||
{{ purchase.CheckSummary }}
|
||||
{{ purchase.orderSum }}
|
||||
</span>
|
||||
</td>
|
||||
<td
|
||||
class="woocommerce-orders-table__cell woocommerce-orders-table__cell-order-actions"
|
||||
data-title="Бонусы"
|
||||
[ngClass]="{
|
||||
'red-color': purchase.BonusSummary ? purchase.BonusSummary < 0 : false,
|
||||
'green-color': purchase.BonusSummary ? purchase.BonusSummary > 0 : false
|
||||
'red-color': purchase.transactionSum ? purchase.transactionSum < 0 : false,
|
||||
'green-color': purchase.transactionSum ? purchase.transactionSum > 0 : false
|
||||
}"
|
||||
>
|
||||
{{ purchase.BonusSummary }}
|
||||
{{ purchase.transactionSum }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Component, Input, OnInit } from '@angular/core';
|
||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||
import { ActivatedRoute, Router } from '@angular/router';
|
||||
import { Purchase } from 'src/app/interface/data';
|
||||
import * as moment from 'moment-timezone';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
||||
import { WpJsonService } from 'src/app/services/wp-json.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { CookiesService } from 'src/app/services/cookies.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-orders',
|
||||
@ -13,6 +16,7 @@ import { JsonrpcService, RpcService } from 'src/app/services/jsonrpc.service';
|
||||
})
|
||||
export class OrdersComponent implements OnInit {
|
||||
@Input() handleHttpError!: (error: HttpErrorResponse) => void;
|
||||
@Output() deauthorization = new EventEmitter<boolean>(false)
|
||||
public lastViewOrder: number = 3;
|
||||
public ordersLoadingStatus: boolean = true;
|
||||
readonly moment = moment;
|
||||
@ -23,31 +27,34 @@ export class OrdersComponent implements OnInit {
|
||||
private route: ActivatedRoute,
|
||||
private router: Router,
|
||||
private jsonrpc: JsonrpcService,
|
||||
private wpJsonService: WpJsonService,
|
||||
private cookiesService: CookiesService,
|
||||
) { }
|
||||
|
||||
ngOnInit(): void {
|
||||
this.getOrders()
|
||||
}
|
||||
|
||||
async getOrders(){
|
||||
const purchases: Purchase[] = (await lastValueFrom(
|
||||
this.jsonrpc.rpc(
|
||||
{
|
||||
method: 'GetAccountPurchase',
|
||||
params: []
|
||||
},
|
||||
RpcService.bonusService
|
||||
)))['Purchases'];
|
||||
async getOrders() {
|
||||
const token = this.cookiesService.getItem('token')
|
||||
if (!token) {
|
||||
this.cookiesService.deleteCookie('token')
|
||||
this.deauthorization.emit(true)
|
||||
return
|
||||
}
|
||||
const purchases = (await lastValueFrom(
|
||||
this.wpJsonService.getTransactions(environment.systemId, token, environment.icardProxy, 30)
|
||||
));
|
||||
|
||||
this.purchases = purchases.map<Purchase>((purchase) => {
|
||||
const id = purchase.ID.slice(0,36).toLowerCase();
|
||||
// purchase.Transactions = transactions.filter((transaction) => {
|
||||
// const same = transaction.Purchase === id;
|
||||
// transaction.HasPurchase = same;
|
||||
// return same;
|
||||
// });
|
||||
return purchase;
|
||||
});
|
||||
// this.purchases = purchases.map<Purchase>((purchase) => {
|
||||
// const id = purchase.ID.slice(0,36).toLowerCase();
|
||||
// // purchase.Transactions = transactions.filter((transaction) => {
|
||||
// // const same = transaction.Purchase === id;
|
||||
// // transaction.HasPurchase = same;
|
||||
// // return same;
|
||||
// // });
|
||||
// return purchase;
|
||||
// });
|
||||
this.purchasesShortArray = this.purchases.slice(0, this.lastViewOrder)
|
||||
this.ordersLoadingStatus = false;
|
||||
}
|
||||
|
||||
@ -17,7 +17,7 @@ export enum Method {
|
||||
})
|
||||
export class WpJsonService {
|
||||
|
||||
protected readonly api = environment.appWPEndpoint;
|
||||
protected readonly api = environment.defaultUrl;
|
||||
private body!: JsonRpcBody;
|
||||
|
||||
constructor(
|
||||
@ -42,8 +42,20 @@ export class WpJsonService {
|
||||
return this._request(`products/${id}`, 'GET');
|
||||
}
|
||||
|
||||
getAllData(): Observable<any> {
|
||||
return this._request('static/nomen_1eb3fb56-3c4c-43b7-9a04-ce532ab7548f.json', 'GET')
|
||||
getAllData(fileName: string): Observable<any> {
|
||||
return this._request(`/static/${fileName}.json`, 'GET')
|
||||
}
|
||||
|
||||
getTerminalList(): Observable<any> {
|
||||
return this._request('/static/terminal_list.json', 'GET')
|
||||
}
|
||||
|
||||
getCustomerInfo(systemId: string, token: string, url: string): Observable<any> {
|
||||
return this._request(`customer_info/${systemId}/${token}/`, 'GET', null, false, url)
|
||||
}
|
||||
|
||||
getTransactions(systemId: string, token: string, url: string, delta: number): Observable<any> {
|
||||
return this._request(`trans/${systemId}/${token}`, 'GET', null, false, url)
|
||||
}
|
||||
|
||||
_request(path: string, method: string, body?: any, auth = false, baseUrl?: string): Observable<any> {
|
||||
|
||||
@ -6,7 +6,7 @@ export const environment = {
|
||||
appBonusEndpoint: 'https://customerapi2.mi.crm4retail.ru/json.rpc/',
|
||||
appWPEndpoint: 'http://213.239.210.240:4500/wp-json/woofood/v1/',
|
||||
hasBonusProgram: true,
|
||||
systemId: 'g6zyv8tj53w28ov7cl',
|
||||
systemId: 'StyrkNFW9vKga1KlJP',
|
||||
defaultUrl: 'https://sakura.lk.crm4retail.ru',
|
||||
firebase: {
|
||||
apiKey: "AIzaSyCnKvln5itnrBj62POCPHxshAN_Vmd0zds",
|
||||
@ -21,6 +21,7 @@ export const environment = {
|
||||
appleWalletEndpoint: 'https://apple-push-notifications.it-retail.tech/apns/api',
|
||||
appleWalletSecret: 'Token F5mbzEERAznGKVbB6l',
|
||||
webhookItRetail: 'https://webhook.it-retail.tech/handlers/tillda/1eb3fb56-3c4c-43b7-9a04-ce532ab7548f',
|
||||
icardProxy: 'https://p1.icard-proxy.crm4retail.ru/',
|
||||
clientName: 'Sakura',
|
||||
cities: ['Менделеевск'],
|
||||
}
|
||||
|
||||
@ -6,7 +6,7 @@ export const environment = {
|
||||
appBonusEndpoint: 'https://customerapi2.mi.crm4retail.ru/json.rpc/',
|
||||
appWPEndpoint: './',
|
||||
hasBonusProgram: true,
|
||||
systemId: 'g6zyv8tj53w28ov7cl',
|
||||
systemId: 'StyrkNFW9vKga1KlJP',
|
||||
defaultUrl: 'http://192.168.0.179:4200',
|
||||
firebase: {
|
||||
apiKey: 'AIzaSyCnKvln5itnrBj62POCPHxshAN_Vmd0zds',
|
||||
@ -21,6 +21,7 @@ export const environment = {
|
||||
appleWalletEndpoint: 'http://192.168.0.179:4200/apns/api',
|
||||
appleWalletSecret: 'Token F5mbzEERAznGKVbB6l',
|
||||
webhookItRetail: 'https://webhook.it-retail.tech/handlers/tillda/1eb3fb56-3c4c-43b7-9a04-ce532ab7548f',
|
||||
icardProxy: 'http://192.168.0.12:4200/icard-proxy/',
|
||||
clientName: 'Sakura',
|
||||
cities: ['Менделеевск'],
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user