Добавил orderid к заказу
This commit is contained in:
Kataev Denis 2023-01-26 01:29:59 +04:00
parent e7a389b484
commit 26aa47b004
7 changed files with 16 additions and 11 deletions

View File

@ -18,7 +18,7 @@
"logLevel": "debug"
},
"/static": {
"target": "https://sakura.lk.crm4retail.ru/static",
"target": "https://demo-stand.lk.crm4retail.ru/static",
"secure": false,
"pathRewrite": {
"^/static": ""

View File

@ -26,7 +26,7 @@ import { lastValueFrom } from 'rxjs';
})
export class UserDataOrderComponent implements OnInit {
@Output() orderSubmitted = new EventEmitter<void>();
@Output() orderSubmitted = new EventEmitter<number>();
readonly cities = environment.cities;
public paymentMethods!: PaymentMethod[];
public loading = false;
@ -55,7 +55,8 @@ export class UserDataOrderComponent implements OnInit {
deliveryType: null,
paymentMethod: null,
comment: '',
persons: 1
persons: 1,
orderid: 0
};
public terminalList!: any;
public selectedTerminal!: any;
@ -175,14 +176,16 @@ export class UserDataOrderComponent implements OnInit {
this.loading = true;
const userData: UserData = this.mainFormGroup.controls['userDataForm'].getRawValue();
userData.phone = this.userData.phone;
const deliveryData = this.mainFormGroup.controls['deliveryDataForm'].getRawValue()
deliveryData.orderid = Math.floor(Math.random() * (10 ** 12))
this.orderService.setUserData(userData);
this.orderService.setDeliveryData(this.mainFormGroup.controls['deliveryDataForm'].getRawValue());
this.orderService.setDeliveryData(deliveryData);
this.orderService.submit().subscribe({
next: (_) => {
this.loading = false;
this.cartService.clearCart();
this.orderSubmitted.next();
this.orderSubmitted.next(deliveryData.orderid);
},
error: () => {
this.loading = false;

View File

@ -231,6 +231,7 @@ export interface DeliveryData {
deliveryType: DeliveryType | null;
persons: number;
comment: string;
orderid: number;
}
export interface PaymentMethod {

View File

@ -46,6 +46,7 @@ export class Order {
persons: 1,
name: "31",
payment: {
orderid: this.deliveryData?.orderid,
delivery_price: 100,
products: this.products.map(product => {
return product.toJson();
@ -54,7 +55,7 @@ export class Order {
subtotal: this.price,
delivery_comment: this.deliveryData?.comment,
delivery: this.deliveryData?.deliveryType?.type,
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? null : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`,
delivery_address: this.deliveryData?.deliveryType?.type === "self_delivery" ? '' : `${environment.cities[0]}, ул ${this.userData?.street}, ${this.userData?.house}`,
amount: this.price + 100,
terminal_id: this.terminal_id
},

View File

@ -193,7 +193,7 @@
<app-user-data-order
*ngIf="orderConfirmed"
(orderSubmitted)="orderSubmitted()"
(orderSubmitted)="orderSubmitted($event)"
></app-user-data-order>
<div #loadingEl *ngIf="loading && !orderConfirmed">

View File

@ -84,9 +84,9 @@ export class CartComponent implements OnInit {
}
}
orderSubmitted() {
orderSubmitted(orderid: number) {
this.visibleSidebar = false
this.messageService.add({ severity: 'success', summary: 'Заказ оформлен!' });
this.messageService.add({ severity: 'success', summary: `Заказ оформлен! Номер заказа: ${orderid}` });
}
confirmClearCart() {

View File

@ -20,8 +20,8 @@ export const environment = {
version: packageJson.version,
appleWalletEndpoint: 'https://apple-push-notifications.it-retail.tech/apns/api',
appleWalletSecret: 'Token F5mbzEERAznGKVbB6l',
webhookItRetail: 'https://demo-stand.lk.crm4retail.ru/it-retail/handlers/tillda/1eb3fb56-3c4c-43b7-9a04-ce532ab7548f',
icardProxy: 'https://p1.icard-proxy.crm4retail.ru/',
webhookItRetail: 'https://demo-stand.lk.crm4retail.ru/api/orders/handlers/tillda/115eaf95-bb44-4cfc-851a-fec5325b45ff',
icardProxy: 'https://demo-stand.lk.crm4retail.ru/api/icard-proxy/',
clientName: 'demo-stand',
cities: ['Менделеевск'],
}