diff --git a/src/app/pages/orders/orders.component.html b/src/app/pages/orders/orders.component.html index 280365b..cdae0aa 100644 --- a/src/app/pages/orders/orders.component.html +++ b/src/app/pages/orders/orders.component.html @@ -150,7 +150,8 @@ {{sumRef}} - + + diff --git a/src/app/pages/orders/orders.component.ts b/src/app/pages/orders/orders.component.ts index e19cbd3..0f2d802 100644 --- a/src/app/pages/orders/orders.component.ts +++ b/src/app/pages/orders/orders.component.ts @@ -34,6 +34,7 @@ export class OrdersComponent implements OnInit { public sumRef1: any = 0; public sumRef2: any = 0; public matchModeOptions!: SelectItem[]; + public dis: boolean = false; public statuses = [ @@ -195,16 +196,15 @@ notif2() { async vievOrder(id: any) { - + this.dis = false; await this.jsonRpcService.rpc2({ method: 'getOrders', params: { "client_id": this.choose, "order_id": id } }, RpcService.authService, false) .subscribe({ next: (result) => { - let data = result.result - - this.order = data + let data = result.result; + this.order = data; }, error: (err) => { console.log('ERROR: ', err) @@ -260,15 +260,57 @@ notif2() { } - async doAdminRefund(id: any, qr_id: any) { - - await this.jsonRpcService.rpc2({ - method: 'doAdminRefund', - params: { "external_id": id, "qr_id": qr_id } + doAdminRefund(id: any, type: any, id_: any) { + this.dis = false; + let qr_id: string; + this.jsonRpcService.rpc2({ + method: 'getOrders', + params: { "client_id": this.choose, "order_id": id_ } }, RpcService.authService, false) .subscribe({ next: (result) => { - let data = result.result + let data = result.result; + let dat: Order = data[0]; + if (dat.payment[0].type == "QR") { + qr_id = dat.payment[0].payload.id; + this.jsonRpcService.rpc2({ + method: 'doAdminRefund', + params: { "external_id": id, "qr_id": qr_id } + }, RpcService.authService, false) + .subscribe({ + next: (result) => { + let data = result.result + this.dis = true; + }, + error: (err) => { + console.log('ERROR: ', err) + this.messageService.add({ + severity: 'error', + summary: 'Произошла ошибка!', + }) + } + } + ); + } else { + this.jsonRpcService.rpc2({ + method: 'doAdminRefund', + params: { "external_id": id} + }, RpcService.authService, false) + .subscribe({ + next: (result) => { + let data = result.result; + this.dis = true; + }, + error: (err) => { + console.log('ERROR: ', err) + this.messageService.add({ + severity: 'error', + summary: 'Произошла ошибка!', + }) + } + } + ); + } }, error: (err) => { console.log('ERROR: ', err) @@ -279,6 +321,24 @@ notif2() { } } ); + //await this.jsonRpcService.rpc2({ + // method: 'doAdminRefund', + // params: { "external_id": id, "qr_id": qr_id } + //}, RpcService.authService, false) + // .subscribe({ + // next: (result) => { + // let data = result.result + // }, + // error: (err) => { + // console.log('ERROR: ', err) + // this.messageService.add({ + // severity: 'error', + // summary: 'Произошла ошибка!', + // }) + // } + // } + // ); + } @@ -316,12 +376,22 @@ notif2() { } } - confirm(id: any, qr_id: any) { - this.confirmationService.confirm({ - message: 'Вы действительно хотите сделать возврат оплаты? Статус заказа при этом не изменится. В случае отмены оплаты необходимо обязательно предупредить кассира.', - accept: () => { - this.doAdminRefund(id, qr_id) - } - }); + confirm(id: any, type: any, id_: any) { + if (type == "QR") { + this.confirmationService.confirm({ + message: 'Вы действительно хотите сделать возврат оплаты и отменить заказ?', + accept: () => { + this.doAdminRefund(id, type, id_) + } + }); + } else { + this.confirmationService.confirm({ + message: 'Вы действительно хотите отменить заказ?', + accept: () => { + this.doAdminRefund(id, type, id_) + } + }); + } + } }