commit
This commit is contained in:
15
src/delivery/delivery.module.ts
Normal file
15
src/delivery/delivery.module.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Module } from '@nestjs/common';
|
||||
import { ShippingController } from './services/shipping.controller';
|
||||
import { ShippingService } from './services/shipping.service';
|
||||
import { OrdersController } from './orders/orders.controller';
|
||||
import { OrdersService } from './orders/orders.service';
|
||||
import { DeliveryOrderController } from './order/delivery-order.controller';
|
||||
import { DeliveryOrderService } from './order/delivery-order.service';
|
||||
|
||||
@Module({
|
||||
imports: [],
|
||||
controllers: [ShippingController, OrdersController,
|
||||
DeliveryOrderController],
|
||||
providers: [ShippingService, OrdersService, DeliveryOrderService],
|
||||
})
|
||||
export class DeliveryModule {}
|
||||
47
src/delivery/order/delivery-order.controller.ts
Normal file
47
src/delivery/order/delivery-order.controller.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Body, Controller, Get, Param, Post } from '@nestjs/common';
|
||||
import { DeliveryOrderModel } from 'src/domain/models/delivery-order.model';
|
||||
import { ImageOrderModel } from 'src/domain/models/image-order.model';
|
||||
import { PaymentModel } from 'src/domain/models/payment.model';
|
||||
import { DeliveryOrderService } from './delivery-order.service';
|
||||
import { ApiExcludeEndpoint } from '@nestjs/swagger';
|
||||
|
||||
@Controller('api/v1/deliveryorder')
|
||||
export class DeliveryOrderController {
|
||||
|
||||
constructor(private readonly deliveryOrderSevive: DeliveryOrderService){}
|
||||
|
||||
@Get('protocolo/:shipmentId/:customerId')
|
||||
@ApiExcludeEndpoint()
|
||||
async getdeliveryByCustomer(@Param("shipmentId") shipmentId: number, @Param("customerId") customerId: number) {
|
||||
return await this.deliveryOrderSevive.getDataDelivery(shipmentId, customerId);
|
||||
}
|
||||
|
||||
@Post('protocolo')
|
||||
@ApiExcludeEndpoint()
|
||||
async createOrReplaceDeliveryByCustomer(@Body() data: DeliveryOrderModel) {
|
||||
return await this.deliveryOrderSevive.createOrReplaceDeliveryOrder(data);
|
||||
}
|
||||
|
||||
@Get('images/:shipmentId/:orderId')
|
||||
@ApiExcludeEndpoint()
|
||||
async getImagesOrder(@Param("shipmentId") shipmentId: number, @Param("orderId") orderId: number) {
|
||||
return await this.deliveryOrderSevive.getImageOrder(shipmentId, orderId);
|
||||
}
|
||||
|
||||
@Post('image')
|
||||
@ApiExcludeEndpoint()
|
||||
async crateImageOrder(@Body() data: ImageOrderModel) {
|
||||
return await this.deliveryOrderSevive.createImageOrder(data);
|
||||
}
|
||||
|
||||
@ApiExcludeEndpoint()
|
||||
@Post('payment')
|
||||
async createPayment(@Body() data: PaymentModel) {
|
||||
return await this.deliveryOrderSevive.createPayment(data);
|
||||
}
|
||||
|
||||
}
|
||||
227
src/delivery/order/delivery-order.service.ts
Normal file
227
src/delivery/order/delivery-order.service.ts
Normal file
@@ -0,0 +1,227 @@
|
||||
/*
|
||||
https://docs.nestjs.com/providers#services
|
||||
*/
|
||||
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Estprotocoloentrega } from 'src/domain/entity/tables/estprotocolo.entity';
|
||||
import { DeliveryOrderModel } from 'src/domain/models/delivery-order.model';
|
||||
import { ImageOrderModel } from 'src/domain/models/image-order.model';
|
||||
import { PaymentModel } from 'src/domain/models/payment.model';
|
||||
import { ResultModel } from 'src/domain/models/result.model';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { Estimagemnota } from '../../domain/entity/tables/estimagemnota.entity';
|
||||
import { Estpagamento } from '../../domain/entity/tables/estpagamento.entity';
|
||||
|
||||
@Injectable()
|
||||
export class DeliveryOrderService {
|
||||
|
||||
async getDataDelivery(shipmentId: number, customerId: number): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const result = await queryRunner.manager
|
||||
.getRepository(Estprotocoloentrega)
|
||||
.createQueryBuilder('estprotocoloentrega')
|
||||
.where('numcar = :numcar and codcli = :codcli', { numcar: shipmentId, codcli: customerId})
|
||||
.getOne();
|
||||
|
||||
return result; //new ResultModel(true, 'Registro localizado com sucesso!', result, {});
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar dados de entrega.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async createOrReplaceDeliveryOrder(data: DeliveryOrderModel): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
console.log(data);
|
||||
try {
|
||||
const updateDelivery = await queryRunner.manager
|
||||
.getRepository(Estprotocoloentrega)
|
||||
.createQueryBuilder('estprotocoloentrega')
|
||||
.where('numcar = :numcar and codcli = :codcli',
|
||||
{ numcar: data.numeroCarregamento, codcli: data.codigoCliente})
|
||||
.getOne();
|
||||
if ( updateDelivery ) {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.update(Estprotocoloentrega)
|
||||
.set({
|
||||
dataEntrega: data.dataEntrega,
|
||||
cpfRecebedor: data.cpfRecebedor,
|
||||
nomeRecebedor: data.nomeRecebedor,
|
||||
urlImagemProtocolo: data.urlImagemProtocolo,
|
||||
latitude: data.latitude,
|
||||
longitude: data.longitude,
|
||||
})
|
||||
.where('numcar = :numcar and codcli = :codcli', { numcar: data.numeroCarregamento, codcli: data.codigoCliente})
|
||||
.execute()
|
||||
} else {
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estprotocoloentrega)
|
||||
.values(data)
|
||||
.execute()
|
||||
}
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Registro atualizado com sucesso!', data, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar dados de entrega.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async getImageOrder(shipmentId: number, orderId: number): Promise<any> {
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const result = await queryRunner.manager
|
||||
.getRepository(Estimagemnota)
|
||||
.createQueryBuilder('estimagemnota')
|
||||
.select(["numnota as \"numeroNota\"", "numped as \"numeroPedido\", numcar as \"numeroCarregamento\""])
|
||||
.addSelect(["tipo as \"tipo\", data as \"data\", url as \"url\", latitude as \"latitude\", longitude as \"longitude\" "])
|
||||
.where('numcar = :numcar and numped = :numped ', { numcar: shipmentId, numped: orderId})
|
||||
.getRawMany();
|
||||
|
||||
return result;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao atualizar imagens da nota fiscal.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
}
|
||||
|
||||
async createImageOrder(dataImage: ImageOrderModel): Promise<any> {
|
||||
console.log(dataImage);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
//const dateDelivery = '2022-04-14T17:52:00';
|
||||
//dataImage.data = dateDelivery;
|
||||
//console.log(dataImage);
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estimagemnota)
|
||||
.values(dataImage)
|
||||
.execute()
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Imagens incluídas com sucesso!', dataImage, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao incluir imagens da nota fiscal.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async createPayment(payment: PaymentModel): Promise<any> {
|
||||
console.log(payment);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
await queryRunner.startTransaction();
|
||||
try {
|
||||
let cobranca = 'PAGV';
|
||||
switch (payment.formaPagto){
|
||||
case 'credit_card_parcelado':
|
||||
cobranca = 'PAGP';
|
||||
break;
|
||||
case 'debit_card':
|
||||
cobranca = 'PAGD';
|
||||
break;
|
||||
case 'credit_card':
|
||||
cobranca = 'PAGV';
|
||||
break;
|
||||
default:
|
||||
cobranca = 'DH';
|
||||
break;
|
||||
};
|
||||
|
||||
await queryRunner.manager
|
||||
.createQueryBuilder()
|
||||
.insert()
|
||||
.into(Estpagamento)
|
||||
.values({
|
||||
orderId: payment.orderId,
|
||||
dataPagamento: payment.dataPagamento,
|
||||
codigoAutorizacao: payment.idTransacao,
|
||||
codigoResposta: '00',
|
||||
dataRequisicao: payment.dataPagamento,
|
||||
dataServidor: payment.dataPagamento,
|
||||
estAcquirer: 'pagseguro',
|
||||
idTransacao: payment.codigoAutorizacao,
|
||||
nsu: payment.nsu,
|
||||
parcelas: payment.parcelas,
|
||||
valor: payment.valor / 100,
|
||||
nomeBandeira: 'pagseguro',
|
||||
formaPagto: payment.formaPagto,
|
||||
codigoFuncionario: null,
|
||||
cobranca: cobranca
|
||||
})
|
||||
.execute()
|
||||
|
||||
await queryRunner.commitTransaction();
|
||||
return new ResultModel(true, 'Pagamento incluído com sucesso!', {}, {});
|
||||
|
||||
} catch (error) {
|
||||
await queryRunner.rollbackTransaction();
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao pagamento para carrgamento / cliente.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
22
src/delivery/orders/orders.controller.ts
Normal file
22
src/delivery/orders/orders.controller.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { OrdersService } from './orders.service';
|
||||
import { ApiExcludeEndpoint } from '@nestjs/swagger';
|
||||
|
||||
@Controller('api/v1/orders')
|
||||
export class OrdersController {
|
||||
|
||||
constructor(private ordersService: OrdersService){}
|
||||
|
||||
@Get('customer/:id')
|
||||
@ApiExcludeEndpoint()
|
||||
async getdeliveryByCustomer(@Param("id") id: number) {
|
||||
return await this.ordersService.GetOrdersByCustomer(id);
|
||||
}
|
||||
|
||||
@Get('payments/:id')
|
||||
@ApiExcludeEndpoint()
|
||||
async getPayments(@Param("id") id: number) {
|
||||
return await this.ordersService.GetPayments(id);
|
||||
}
|
||||
|
||||
}
|
||||
127
src/delivery/orders/orders.service.ts
Normal file
127
src/delivery/orders/orders.service.ts
Normal file
@@ -0,0 +1,127 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Pcpedc } from 'src/domain/entity/tables/pcpedc.entity';
|
||||
import { Pcpedi } from 'src/domain/entity/tables/pcpedi.entity';
|
||||
import { ResultModel } from 'src/domain/models/result.model';
|
||||
import { getConnection } from 'typeorm';
|
||||
import { Estpagamento } from '../../domain/entity/tables/estpagamento.entity';
|
||||
|
||||
@Injectable()
|
||||
export class OrdersService {
|
||||
|
||||
async GetOrdersByCustomer(id: number): Promise<any> {
|
||||
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
|
||||
await queryRunner.connect();
|
||||
|
||||
try {
|
||||
|
||||
const user = { matricula: 154969 }; //await this.GetUser(queryRunner); 2854
|
||||
|
||||
if (user == null) {
|
||||
return new ResultModel(false, 'Não foi possível localizar notas para este usuário',
|
||||
null,
|
||||
'Não foi localizado motorista para este usuário.');
|
||||
}
|
||||
|
||||
const orders = await queryRunner.manager
|
||||
.getRepository(Pcpedc)
|
||||
.createQueryBuilder('pcpedc')
|
||||
.innerJoinAndSelect('pcpedc.pcclient', 'pcclient')
|
||||
.innerJoinAndSelect('pcpedc.pccarreg', 'pccarreg',
|
||||
'pccarreg.codmotorista = :matricula ', //AND pccarreg.dtfecha is null',
|
||||
{ matricula: user.matricula })
|
||||
.leftJoinAndSelect('pcpedc.pcclientendent', 'pcclientendent')
|
||||
.innerJoinAndSelect("pcpedc.pcplpag", "pcplpag")
|
||||
.select(['pcpedc.numcar as "numeroCarga"',
|
||||
'NVL(pcpedc.numnota, pcpedc.numcupom) as "numeroNota"',
|
||||
'pcpedc.dtfat as "dataEmissao"',
|
||||
'pcpedc.numped as "numeroPedido"',
|
||||
'TRUNC(pcpedc.vlatend * 100) as "valorNota"',
|
||||
'pcpedc.codcli as "codigoCliente"',
|
||||
'pcclient.cliente as "nomeCliente"',
|
||||
'NVL(pcclientendent.enderent, pcclient.enderent) as "endereco"',
|
||||
'NVL(pcclientendent.numeroent, pcclient.numeroent) as "numero"',
|
||||
'NVL(pcclientendent.bairroent, pcclient.bairroent) as "bairro"',
|
||||
'NVL(pcclientendent.complementoent, pcclient.complementoent) as "complemento"',
|
||||
'NVL(pcclientendent.municent, pcclient.municent) as "cidade"',
|
||||
'NVL(pcclientendent.estent, pcclient.estent) as "estado"',
|
||||
'NVL(pcclientendent.cepent, pcclient.cepent) as "cep"',
|
||||
'pcclient.pontorefer as "pontoReferencia"',
|
||||
'pcpedc.codendentcli as "codigoEnderecoEntrega"',
|
||||
'pcclientendent.telent as "telefoneEntrega"',
|
||||
'pcclient.telent as "telefoneCliente"',
|
||||
'pcclient.telcelent as "celularCliente"',
|
||||
'pcplpag.descricao as "planoPagamento"',
|
||||
'NVL(\"pcplpag\".NUMPARCELAS,0) as "numeroParcelas"',
|
||||
'NVL((select sum(trunc(pccrecli.valor*100)) from pccrecli where pccrecli.numtransvendadesc = \"pcpedc\".numtransvenda),0) as "valorCreditos"',
|
||||
'NVL((select sum(trunc(pcestcom.vldevolucao*100)) from pcestcom where pcestcom.numtransvenda = \"pcpedc\".numtransvenda),0) as "valorDevolucoes"',
|
||||
'NVL((select sum(trunc(estpagamento.valor*100)) from estpagamento where estpagamento.numorca = \"pcpedc\".numped),0) as "valorRecebimentos"',
|
||||
'NVL((select count(1) from estimagemnota where estimagemnota.numped = \"pcpedc\".numped and estimagemnota.tipo = \'P\'),0) as "notaComImagens"',
|
||||
'NVL((select count(1) from estimagemnota where estimagemnota.numped = \"pcpedc\".numped and estimagemnota.tipo = \'C\'),0) as "notaComProtocolo"',
|
||||
'NVL((select count(1) from estprotocoloentrega where estprotocoloentrega.numcar = \"pcpedc\".numcar and estprotocoloentrega.codcli = pcpedc.codcli),0) as "notaComDadosRecebedor"',
|
||||
])
|
||||
.addSelect(subQuery => {
|
||||
return subQuery
|
||||
.select('count(distinct item.codfilialretira)', 'lojas')
|
||||
.from(Pcpedi, 'item')
|
||||
.where('item.numped = pcpedc.numped and item.codfilialretira <> pcpedc.codfilial')
|
||||
}, 'lojas')
|
||||
.where("pcpedc.posicao = 'F'")
|
||||
.andWhere("pcpedc.codcli = :codcli", { codcli: id })
|
||||
.getRawMany();
|
||||
return orders;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao consultar notas fiscais.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async GetPayments(id: number) {
|
||||
// const user = await this.GetUser(queryRunner);
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const payments = await queryRunner.manager
|
||||
.getRepository(Estpagamento)
|
||||
.createQueryBuilder('estpagamento')
|
||||
.select(['\"estpagamento\".numorca as "orderId"',
|
||||
'TRUNC(\"estpagamento\".valor * 100) as "valor"',
|
||||
'\"estpagamento\".nsu as "nsu"',
|
||||
'\"estpagamento\".dtpagamento as "dataPagamento"',
|
||||
'\"estpagamento\".codautorizacao as "codigoAutorizacao"',
|
||||
'\"estpagamento\".idtransacao as "idTransacao"',
|
||||
'\"estpagamento\".parcelas as "parcelas"',
|
||||
'\"estpagamento\".formapagto as "formaPagto"',
|
||||
])
|
||||
.innerJoin('estpagamento.pedido', 'pcpedc')
|
||||
.innerJoin('pcpedc.pcclient', 'pcclient')
|
||||
//.innerJoin('pcpedc.pccarreg', 'pccarreg',
|
||||
// 'pccarreg.codmotorista1 = :matricula ', //AND pccarreg.dtfecha is null',
|
||||
// { matricula: user.matricula })
|
||||
.where('\"pcpedc\".codcli = :id', { id })
|
||||
.getRawMany()
|
||||
return payments;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false,
|
||||
'Erro ao consultar pagamentos.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
29
src/delivery/services/shipping.controller.ts
Normal file
29
src/delivery/services/shipping.controller.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { ShippingService } from './shipping.service';
|
||||
import { ApiExcludeEndpoint } from '@nestjs/swagger';
|
||||
|
||||
@Controller('api/v1/shipping')
|
||||
export class ShippingController {
|
||||
|
||||
constructor(private shippingService: ShippingService){}
|
||||
|
||||
@Get('customer')
|
||||
@ApiExcludeEndpoint()
|
||||
async getdeliveryByCustomer() {
|
||||
return await this.shippingService.GetShippingsByCustomer();
|
||||
}
|
||||
|
||||
@Get('collect/shop')
|
||||
@ApiExcludeEndpoint()
|
||||
async getCollectbyShop() {
|
||||
return await this.shippingService.GetCollectByShop();
|
||||
}
|
||||
|
||||
@Get('collect/customer/:id')
|
||||
@ApiExcludeEndpoint()
|
||||
async getCollectbyCustomer(@Param('id') id: string) {
|
||||
return await this.shippingService.GetCollectByCustomer(id);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
161
src/delivery/services/shipping.service.ts
Normal file
161
src/delivery/services/shipping.service.ts
Normal file
@@ -0,0 +1,161 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { Esventregasporcliente } from 'src/domain/entity/views/esventregasporcliente.entity';
|
||||
import { Connection, getConnection } from 'typeorm';
|
||||
import { ResultModel } from '../../domain/models/result.model';
|
||||
import { Esvretiralojascliente } from '../../domain/entity/views/esventregaslojascliente.entity';
|
||||
import { EsvRetiraLojas } from '../../domain/entity/views/esvretiralojas.entity';
|
||||
|
||||
@Injectable()
|
||||
export class ShippingService {
|
||||
constructor(private connection: Connection) { }
|
||||
|
||||
async GetShippingsByCustomer(): Promise<any> {
|
||||
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
|
||||
await queryRunner.connect();
|
||||
|
||||
try {
|
||||
|
||||
/*const user = await this.GetUser(queryRunner);
|
||||
|
||||
if (user == null) {
|
||||
return new ResultModel(false, 'Não foi possível localizar entregas para este usuário',
|
||||
null,
|
||||
'Não foi localizado motorista para este usuário.');
|
||||
}*/
|
||||
|
||||
const deliveries = await queryRunner.manager
|
||||
.getRepository(Esventregasporcliente)
|
||||
.createQueryBuilder('ESVENTREGASPORCLIENTE')
|
||||
.select(['cliente as "nomeCliente"'
|
||||
, 'cgcent as "cnpj_cpf"'
|
||||
, 'email as "email"'
|
||||
, 'endereco as "endereco"'
|
||||
, 'numero as "numero"'
|
||||
, 'bairro as "bairro"'
|
||||
, 'complemento as "complemento"'
|
||||
, 'cidade as "cidade"'
|
||||
, 'estado as "uf"'
|
||||
, 'cep as "cep"'
|
||||
, 'qtpedidos as "quantidadePedidos"'
|
||||
, 'qtlojas as "quantidaeLojas"'
|
||||
, 'entrega_concluida as "entregaConcluida"'
|
||||
, 'telefone as "telefoneCliente"'
|
||||
, 'celular as "celularCliente"'
|
||||
, 'codcli as "codigoCliente"'])
|
||||
.where("email = 'eduardoestevao.gyn@gmail.com'")
|
||||
.getRawMany();
|
||||
|
||||
return deliveries;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false, 'Não foi possível consultar as entregas por cliente.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
async GetCollectByShop(): Promise<any> {
|
||||
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
|
||||
await queryRunner.connect();
|
||||
|
||||
try {
|
||||
|
||||
/*const user = await this.GetUser(queryRunner);
|
||||
|
||||
if (user == null) {
|
||||
return new ResultModel(false, 'Não foi possível localizar entregas para este usuário',
|
||||
null,
|
||||
'Não foi localizado motorista para este usuário.');
|
||||
}*/
|
||||
|
||||
const deliveries = await queryRunner.manager
|
||||
.getRepository(EsvRetiraLojas)
|
||||
.createQueryBuilder('ESVRETIRALOJAS')
|
||||
.select(['codigo as "codigoLoja"'
|
||||
, 'razaosocial as "razaoSocial"'
|
||||
, 'quantidadepedidos as "quantidadePedidos"'
|
||||
])
|
||||
.where("email = 'eduardoestevao.gyn@gmail.com'")
|
||||
.getRawMany();
|
||||
|
||||
return deliveries;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false, 'Não foi possível consultar as coletas por loja.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
async GetCollectByCustomer(id: string): Promise<any> {
|
||||
|
||||
const connection = getConnection();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
|
||||
await queryRunner.connect();
|
||||
|
||||
try {
|
||||
|
||||
/*const user = await this.GetUser(queryRunner);
|
||||
|
||||
if (user == null) {
|
||||
return new ResultModel(false, 'Não foi possível localizar entregas para este usuário',
|
||||
null,
|
||||
'Não foi localizado motorista para este usuário.');
|
||||
}*/
|
||||
|
||||
const deliveries = await queryRunner.manager
|
||||
.getRepository(Esvretiralojascliente)
|
||||
.createQueryBuilder('ESVRETIRALOJASCLIENTE')
|
||||
.select([
|
||||
'codfilial as "codigoFilial"'
|
||||
,'numped as "numeroPedido"'
|
||||
,'numnota as "numeroNota"'
|
||||
,'dtfat as "dataFaturamento"'
|
||||
,'datapedido as "dataPedido"'
|
||||
,'codcli as "codigoCliente"'
|
||||
,'cliente as "nomeCliente"'
|
||||
,'codfilialretira as "codigoLoja"'
|
||||
,'razaosocial as "nomeLoja"'
|
||||
,'qtitens as "quantidadeItens"'
|
||||
,'quantidade as "quantidade"'
|
||||
])
|
||||
.where("email = 'eduardoestevao.gyn@gmail.com'")
|
||||
.andWhere("codfilial = :codfilial", {codfilial: id})
|
||||
.getRawMany();
|
||||
|
||||
return deliveries;
|
||||
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return new ResultModel(false, 'Não foi possível consultar as coletas por cliente.',
|
||||
null,
|
||||
error);
|
||||
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user