first
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Injectable, Inject } from '@nestjs/common';
|
||||
import { Injectable, Inject, HttpStatus } from '@nestjs/common';
|
||||
import { FindOrdersDto } from '../dto/find-orders.dto';
|
||||
import { InvoiceDto } from '../dto/find-invoice.dto';
|
||||
import { CutItemDto } from '../dto/CutItemDto';
|
||||
@@ -12,14 +12,24 @@ import { OrderDeliveryDto } from '../dto/OrderDeliveryDto';
|
||||
import { OrderTransferDto } from '../dto/OrderTransferDto';
|
||||
import { OrderStatusDto } from '../dto/OrderStatusDto';
|
||||
import { InvoiceCheckDto } from '../dto/invoice-check.dto';
|
||||
|
||||
import { LeadtimeDto } from '../dto/leadtime.dto';
|
||||
import { HttpException } from '@nestjs/common/exceptions/http.exception';
|
||||
import { CarrierDto } from '../../data-consult/dto/carrier.dto';
|
||||
import { MarkData } from '../interface/markdata';
|
||||
import { EstLogTransferFilterDto, EstLogTransferResponseDto } from '../dto/estlogtransfer.dto';
|
||||
|
||||
|
||||
@Injectable()
|
||||
export class OrdersService {
|
||||
private readonly TTL_ORDERS = 60 * 10; // 10 minutos
|
||||
private readonly TTL_ORDERS = 60 * 30; // 30 minutos
|
||||
private readonly TTL_INVOICE = 60 * 60; // 1 hora
|
||||
private readonly TTL_ITENS = 60 * 10; // 10 minutos
|
||||
private readonly TTL_LEADTIME = 60 * 360; // 6 horas
|
||||
private readonly TTL_DELIVERIES = 60 * 10; // 10 minutos
|
||||
private readonly TTL_TRANSFER = 60 * 15; // 15 minutos
|
||||
private readonly TTL_STATUS = 60 * 5; // 5 minutos
|
||||
private readonly TTL_CARRIERS = 60 * 20; // 20 minutos
|
||||
private readonly TTL_MARKS = 60 * 25; // 25 minutos
|
||||
|
||||
constructor(
|
||||
private readonly ordersRepository: OrdersRepository,
|
||||
@@ -31,7 +41,6 @@ export class OrdersService {
|
||||
*/
|
||||
async findOrders(query: FindOrdersDto) {
|
||||
const key = `orders:query:${this.hashObject(query)}`;
|
||||
|
||||
return getOrSetCache(
|
||||
this.redisClient,
|
||||
key,
|
||||
@@ -40,6 +49,65 @@ export class OrdersService {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar pedidos por data de entrega com cache
|
||||
*/
|
||||
async findOrdersByDeliveryDate(query: any) {
|
||||
const key = `orders:delivery:${this.hashObject(query)}`;
|
||||
return getOrSetCache(
|
||||
this.redisClient,
|
||||
key,
|
||||
this.TTL_ORDERS,
|
||||
() => this.ordersRepository.findOrdersByDeliveryDate(query),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar pedidos com resultados de fechamento de caixa
|
||||
*/
|
||||
async findOrdersWithCheckout(query: FindOrdersDto) {
|
||||
const key = `orders:checkout:${this.hashObject(query)}`;
|
||||
return getOrSetCache(
|
||||
this.redisClient,
|
||||
key,
|
||||
this.TTL_ORDERS,
|
||||
async () => {
|
||||
// Primeiro obtém a lista de pedidos
|
||||
const orders = await this.findOrders(query);
|
||||
// Para cada pedido, busca o fechamento de caixa
|
||||
const results = await Promise.all(
|
||||
orders.map(async order => {
|
||||
try {
|
||||
const checkout = await this.ordersRepository.findOrderWithCheckoutByOrder(
|
||||
Number(order.orderId),
|
||||
);
|
||||
return { ...order, checkout };
|
||||
} catch {
|
||||
return { ...order, checkout: null };
|
||||
}
|
||||
}),
|
||||
);
|
||||
return results;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async getOrderCheckout(orderId: number) {
|
||||
const key = `orders:checkout:${orderId}`;
|
||||
return getOrSetCache(
|
||||
this.redisClient,
|
||||
key,
|
||||
this.TTL_ORDERS,
|
||||
async () => {
|
||||
const result = await this.ordersRepository.findOrderWithCheckoutByOrder(orderId);
|
||||
if (!result) {
|
||||
throw new HttpException('Nenhum fechamento encontrado', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar nota fiscal por chave NFe com cache
|
||||
*/
|
||||
@@ -93,42 +161,169 @@ export class OrdersService {
|
||||
});
|
||||
}
|
||||
|
||||
async getCutItens(orderId: string): Promise<CutItemDto[]> {
|
||||
const itens = await this.ordersRepository.getCutItens(orderId);
|
||||
/**
|
||||
* Buscar entregas do pedido com cache
|
||||
*/
|
||||
async getOrderDeliveries(
|
||||
orderId: string,
|
||||
query: { createDateIni: string; createDateEnd: string },
|
||||
): Promise<OrderDeliveryDto[]> {
|
||||
const key = `orders:deliveries:${orderId}:${query.createDateIni}:${query.createDateEnd}`;
|
||||
|
||||
return itens.map(item => ({
|
||||
productId: Number(item.productId),
|
||||
description: item.description,
|
||||
pacth: item.pacth,
|
||||
stockId: Number(item.stockId),
|
||||
saleQuantity: Number(item.saleQuantity),
|
||||
cutQuantity: Number(item.cutQuantity),
|
||||
separedQuantity: Number(item.separedQuantity),
|
||||
}));
|
||||
return getOrSetCache(
|
||||
this.redisClient,
|
||||
key,
|
||||
this.TTL_DELIVERIES,
|
||||
() => this.ordersRepository.getOrderDeliveries(orderId, query),
|
||||
);
|
||||
}
|
||||
|
||||
async getCutItens(orderId: string): Promise<CutItemDto[]> {
|
||||
const key = `orders:cutitens:${orderId}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_ITENS, async () => {
|
||||
const itens = await this.ordersRepository.getCutItens(orderId);
|
||||
|
||||
return itens.map(item => ({
|
||||
productId: Number(item.productId),
|
||||
description: item.description,
|
||||
pacth: item.pacth,
|
||||
stockId: Number(item.stockId),
|
||||
saleQuantity: Number(item.saleQuantity),
|
||||
cutQuantity: Number(item.cutQuantity),
|
||||
separedQuantity: Number(item.separedQuantity),
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
async getOrderDelivery(orderId: string): Promise<OrderDeliveryDto> {
|
||||
return this.ordersRepository.getOrderDelivery(orderId);
|
||||
const key = `orders:delivery:${orderId}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_DELIVERIES, () =>
|
||||
this.ordersRepository.getOrderDelivery(orderId),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar leadtime do pedido com cache
|
||||
*/
|
||||
async getLeadtime(orderId: string): Promise<LeadtimeDto[]> {
|
||||
const key = `orders:leadtime:${orderId}`;
|
||||
return getOrSetCache(
|
||||
this.redisClient,
|
||||
key,
|
||||
this.TTL_LEADTIME,
|
||||
() => this.ordersRepository.getLeadtimeWMS(orderId)
|
||||
);
|
||||
}
|
||||
|
||||
async getTransfer(orderId: number): Promise<OrderTransferDto[] | null> {
|
||||
return this.ordersRepository.getTransfer(orderId);
|
||||
const key = `orders:transfer:${orderId}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_TRANSFER, () =>
|
||||
this.ordersRepository.getTransfer(orderId),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar log de transferência por ID do pedido com cache
|
||||
*/
|
||||
async getTransferLog(
|
||||
orderId: number,
|
||||
filters?: EstLogTransferFilterDto
|
||||
): Promise<EstLogTransferResponseDto[] | null> {
|
||||
const key = `orders:transfer-log:${orderId}:${this.hashObject(filters || {})}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_TRANSFER, () =>
|
||||
this.ordersRepository.estlogtransfer(orderId, filters),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar logs de transferência com filtros (sem especificar pedido específico)
|
||||
*/
|
||||
async getTransferLogs(
|
||||
filters?: EstLogTransferFilterDto
|
||||
): Promise<EstLogTransferResponseDto[] | null> {
|
||||
const key = `orders:transfer-logs:${this.hashObject(filters || {})}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_TRANSFER, () =>
|
||||
this.ordersRepository.estlogtransfers(filters),
|
||||
);
|
||||
}
|
||||
|
||||
async getStatusOrder(orderId: number): Promise<OrderStatusDto[] | null> {
|
||||
return this.ordersRepository.getStatusOrder(orderId);
|
||||
const key = `orders:status:${orderId}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_STATUS, () =>
|
||||
this.ordersRepository.getStatusOrder(orderId),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utilitário para gerar hash MD5 de objetos
|
||||
* Utilitário para gerar hash MD5 de objetos
|
||||
*/
|
||||
private hashObject(obj: any): string {
|
||||
const str = JSON.stringify(obj, Object.keys(obj).sort());
|
||||
return createHash('md5').update(str).digest('hex');
|
||||
}
|
||||
|
||||
async createInvoiceCheck(invoice: InvoiceCheckDto): Promise<{ message: string }> {
|
||||
// Não usa cache para operações de escrita
|
||||
return this.ordersRepository.createInvoiceCheck(invoice);
|
||||
}
|
||||
|
||||
async createInvoiceCheck(invoice: InvoiceCheckDto): Promise<{ message: string }> {
|
||||
return this.ordersRepository.createInvoiceCheck(invoice);
|
||||
}
|
||||
/**
|
||||
* Buscar transportadoras do pedido com cache
|
||||
*/
|
||||
async getOrderCarriers(orderId: number): Promise<CarrierDto[]> {
|
||||
const key = `orders:carriers:${orderId}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_CARRIERS, async () => {
|
||||
const carriers = await this.ordersRepository.getOrderCarriers(orderId);
|
||||
|
||||
return carriers.map(carrier => ({
|
||||
carrierId: carrier.carrierId?.toString() || '',
|
||||
carrierName: carrier.carrierName || '',
|
||||
carrierDescription: carrier.carrierDescription || '',
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar marca por ID com cache
|
||||
*/
|
||||
async findOrderByMark(orderId: number): Promise<MarkData> {
|
||||
const key = `orders:mark:${orderId}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_MARKS, async () => {
|
||||
const result = await this.ordersRepository.findorderbymark(orderId);
|
||||
if (!result) {
|
||||
throw new HttpException('Marca não encontrada', HttpStatus.NOT_FOUND);
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar todas as marcas disponíveis com cache
|
||||
*/
|
||||
async getAllMarks(): Promise<MarkData[]> {
|
||||
const key = 'orders:marks:all';
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_MARKS, async () => {
|
||||
return await this.ordersRepository.getAllMarks();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Buscar marcas por nome com cache
|
||||
*/
|
||||
async getMarksByName(markName: string): Promise<MarkData[]> {
|
||||
const key = `orders:marks:name:${markName}`;
|
||||
|
||||
return getOrSetCache(this.redisClient, key, this.TTL_MARKS, async () => {
|
||||
return await this.ordersRepository.getMarksByName(markName);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -11,39 +11,96 @@ import {
|
||||
ValidationPipe,
|
||||
HttpException,
|
||||
HttpStatus,
|
||||
DefaultValuePipe,
|
||||
ParseBoolPipe,
|
||||
} from '@nestjs/common';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags } from '@nestjs/swagger';
|
||||
import { ApiBearerAuth, ApiOperation, ApiTags, ApiQuery, ApiParam, ApiResponse } from '@nestjs/swagger';
|
||||
import { ResponseInterceptor } from '../../common/response.interceptor';
|
||||
import { OrdersService } from '../application/orders.service';
|
||||
import { FindOrdersDto } from '../dto/find-orders.dto';
|
||||
import { JwtAuthGuard } from 'src/auth/guards/jwt-auth.guard';
|
||||
import { FindOrdersByDeliveryDateDto } from '../dto/find-orders-by-delivery-date.dto';
|
||||
import { JwtAuthGuard, } from 'src/auth/guards/jwt-auth.guard';
|
||||
import { InvoiceDto } from '../dto/find-invoice.dto';
|
||||
import { OrderItemDto } from "../dto/OrderItemDto";
|
||||
import { LeadtimeDto } from '../dto/leadtime.dto';
|
||||
import { CutItemDto } from '../dto/CutItemDto';
|
||||
import { OrderDeliveryDto } from '../dto/OrderDeliveryDto';
|
||||
import { OrderTransferDto } from '../dto/OrderTransferDto';
|
||||
import { OrderStatusDto } from '../dto/OrderStatusDto';
|
||||
import { InvoiceCheckDto } from '../dto/invoice-check.dto';
|
||||
|
||||
|
||||
|
||||
import { ParseIntPipe } from '@nestjs/common/pipes/parse-int.pipe';
|
||||
import { CarrierDto } from 'src/data-consult/dto/carrier.dto';
|
||||
import { OrderResponseDto } from '../dto/order-response.dto';
|
||||
import { MarkResponseDto } from '../dto/mark-response.dto';
|
||||
import { EstLogTransferResponseDto } from '../dto/estlogtransfer.dto';
|
||||
|
||||
|
||||
@ApiTags('Orders')
|
||||
@ApiBearerAuth()
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@UseInterceptors(ResponseInterceptor)
|
||||
//@ApiBearerAuth()
|
||||
//@UseGuards(JwtAuthGuard)
|
||||
@Controller('api/v1/orders')
|
||||
export class OrdersController {
|
||||
constructor(private readonly ordersService: OrdersService) {}
|
||||
|
||||
@Get('find')
|
||||
@ApiOperation({
|
||||
summary: 'Busca pedidos',
|
||||
description: 'Busca pedidos com filtros avançados. Suporta filtros por data, cliente, vendedor, status, tipo de entrega e status de transferência.'
|
||||
})
|
||||
@ApiQuery({ name: 'includeCheckout', required: false, type: 'boolean', description: 'Incluir dados de checkout' })
|
||||
@ApiQuery({ name: 'statusTransfer', required: false, type: 'string', description: 'Filtrar por status de transferência (Em Trânsito, Em Separação, Aguardando Separação, Concluída)' })
|
||||
@ApiQuery({ name: 'markId', required: false, type: 'number', description: 'ID da marca para filtrar pedidos' })
|
||||
@ApiQuery({ name: 'markName', required: false, type: 'string', description: 'Nome da marca para filtrar pedidos (busca parcial)' })
|
||||
@ApiQuery({ name: 'hasPreBox', required: false, type: 'boolean', description: 'Filtrar pedidos que tenham registros na tabela de transfer log' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
findOrders(@Query() query: FindOrdersDto) {
|
||||
@ApiResponse({ status: 200, description: 'Lista de pedidos retornada com sucesso', type: [OrderResponseDto] })
|
||||
findOrders(
|
||||
@Query() query: FindOrdersDto,
|
||||
@Query('includeCheckout', new DefaultValuePipe(false), ParseBoolPipe)
|
||||
includeCheckout: boolean,
|
||||
) {
|
||||
if (includeCheckout) {
|
||||
return this.ordersService.findOrdersWithCheckout(query);
|
||||
}
|
||||
return this.ordersService.findOrders(query);
|
||||
}
|
||||
|
||||
@Get('find-by-delivery-date')
|
||||
@ApiOperation({
|
||||
summary: 'Busca pedidos por data de entrega',
|
||||
description: 'Busca pedidos filtrados por data de entrega. Suporta filtros adicionais como status de transferência, cliente, vendedor, etc.'
|
||||
})
|
||||
@ApiQuery({ name: 'statusTransfer', required: false, type: 'string', description: 'Filtrar por status de transferência (Em Trânsito, Em Separação, Aguardando Separação, Concluída)' })
|
||||
@ApiQuery({ name: 'markId', required: false, type: 'number', description: 'ID da marca para filtrar pedidos' })
|
||||
@ApiQuery({ name: 'markName', required: false, type: 'string', description: 'Nome da marca para filtrar pedidos (busca parcial)' })
|
||||
@ApiQuery({ name: 'hasPreBox', required: false, type: 'boolean', description: 'Filtrar pedidos que tenham registros na tabela de transfer log' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@ApiResponse({ status: 200, description: 'Lista de pedidos por data de entrega retornada com sucesso', type: [OrderResponseDto] })
|
||||
findOrdersByDeliveryDate(
|
||||
@Query() query: FindOrdersByDeliveryDateDto,
|
||||
) {
|
||||
return this.ordersService.findOrdersByDeliveryDate(query);
|
||||
}
|
||||
|
||||
@Get(':orderId/checkout')
|
||||
@ApiOperation({ summary: 'Busca fechamento de caixa para um pedido' })
|
||||
@ApiParam({ name: 'orderId', example: 236001388 })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
getOrderCheckout(
|
||||
@Param('orderId', ParseIntPipe) orderId: number,
|
||||
) {
|
||||
return this.ordersService.getOrderCheckout(orderId);
|
||||
}
|
||||
|
||||
|
||||
@Get('invoice/:chavenfe')
|
||||
@ApiParam({
|
||||
name: 'chavenfe',
|
||||
required: true,
|
||||
description: 'Chave da Nota Fiscal (44 dígitos)',
|
||||
example: '35191234567890000123550010000000011000000010',
|
||||
})
|
||||
|
||||
@ApiOperation({ summary: 'Busca NF pela chave' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getInvoice(@Param('chavenfe') chavenfe: string): Promise<InvoiceDto> {
|
||||
@@ -56,12 +113,14 @@ export class OrdersController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('itens/:orderId')
|
||||
@ApiOperation({ summary: 'Busca PELO numero do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: '236001388' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getItens(@Param('orderId') orderId: string): Promise<OrderItemDto[]> {
|
||||
async getItens(@Param('orderId', ParseIntPipe) orderId: number): Promise<OrderItemDto[]> {
|
||||
try {
|
||||
return await this.ordersService.getItens(orderId);
|
||||
return await this.ordersService.getItens(orderId.toString());
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar itens do pedido',
|
||||
@@ -71,10 +130,11 @@ export class OrdersController {
|
||||
}
|
||||
@Get('cut-itens/:orderId')
|
||||
@ApiOperation({ summary: 'Busca itens cortados do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: '236001388' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getCutItens(@Param('orderId') orderId: string): Promise<CutItemDto[]> {
|
||||
async getCutItens(@Param('orderId', ParseIntPipe) orderId: number): Promise<CutItemDto[]> {
|
||||
try {
|
||||
return await this.ordersService.getCutItens(orderId);
|
||||
return await this.ordersService.getCutItens(orderId.toString());
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar itens cortados',
|
||||
@@ -82,13 +142,14 @@ export class OrdersController {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Get('delivery/:orderId')
|
||||
@ApiOperation({ summary: 'Busca dados de entrega do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: '236001388' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getOrderDelivery(@Param('orderId') orderId: string): Promise<OrderDeliveryDto | null> {
|
||||
async getOrderDelivery(@Param('orderId', ParseIntPipe) orderId: number): Promise<OrderDeliveryDto | null> {
|
||||
try {
|
||||
return await this.ordersService.getOrderDelivery(orderId);
|
||||
return await this.ordersService.getOrderDelivery(orderId.toString());
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar dados de entrega',
|
||||
@@ -98,9 +159,10 @@ export class OrdersController {
|
||||
}
|
||||
|
||||
@Get('transfer/:orderId')
|
||||
@ApiOperation({ summary: 'Consulta pedidos de transferência' })
|
||||
@ApiOperation({ summary: 'Consulta pedidos de transferência' })
|
||||
@ApiParam({ name: 'orderId', example: 236001388 })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getTransfer(@Param('orderId') orderId: number): Promise<OrderTransferDto[] | null> {
|
||||
async getTransfer(@Param('orderId', ParseIntPipe) orderId: number): Promise<OrderTransferDto[] | null> {
|
||||
try {
|
||||
return await this.ordersService.getTransfer(orderId);
|
||||
} catch (error) {
|
||||
@@ -113,8 +175,9 @@ async getTransfer(@Param('orderId') orderId: number): Promise<OrderTransferDto[]
|
||||
|
||||
@Get('status/:orderId')
|
||||
@ApiOperation({ summary: 'Consulta status do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: 236001388 })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getStatusOrder(@Param('orderId') orderId: number): Promise<OrderStatusDto[] | null> {
|
||||
async getStatusOrder(@Param('orderId', ParseIntPipe) orderId: number): Promise<OrderStatusDto[] | null> {
|
||||
try {
|
||||
return await this.ordersService.getStatusOrder(orderId);
|
||||
} catch (error) {
|
||||
@@ -125,6 +188,43 @@ async getStatusOrder(@Param('orderId') orderId: number): Promise<OrderStatusDto[
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Get(':orderId/deliveries')
|
||||
@ApiOperation({ summary: 'Consulta entregas do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: '236001388' })
|
||||
@ApiQuery({ name: 'createDateIni', required: false, description: 'Data inicial para filtro (formato YYYY-MM-DD)' })
|
||||
@ApiQuery({ name: 'createDateEnd', required: false, description: 'Data final para filtro (formato YYYY-MM-DD)' })
|
||||
async getOrderDeliveries(
|
||||
@Param('orderId', ParseIntPipe) orderId: number,
|
||||
@Query('createDateIni') createDateIni?: string,
|
||||
@Query('createDateEnd') createDateEnd?: string,
|
||||
): Promise<OrderDeliveryDto[]> {
|
||||
// Definir datas padrão caso não sejam fornecidas
|
||||
const defaultDateIni = createDateIni || new Date(new Date().setDate(new Date().getDate() - 30)).toISOString().split('T')[0];
|
||||
const defaultDateEnd = createDateEnd || new Date().toISOString().split('T')[0];
|
||||
|
||||
return this.ordersService.getOrderDeliveries(orderId.toString(), {
|
||||
createDateIni: defaultDateIni,
|
||||
createDateEnd: defaultDateEnd,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Get('leadtime/:orderId')
|
||||
@ApiOperation({ summary: 'Consulta leadtime do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: '236001388' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getLeadtime(@Param('orderId', ParseIntPipe) orderId: number): Promise<LeadtimeDto[]> {
|
||||
try {
|
||||
return await this.ordersService.getLeadtime(orderId.toString());
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar leadtime do pedido',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Post('invoice/check')
|
||||
@ApiOperation({ summary: 'Cria conferência de nota fiscal' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@@ -137,5 +237,147 @@ async createInvoiceCheck(@Body() invoice: InvoiceCheckDto): Promise<{ message: s
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Get('carriers/:orderId')
|
||||
@ApiOperation({ summary: 'Busca transportadoras do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: 236001388 })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
async getOrderCarriers(@Param('orderId', ParseIntPipe) orderId: number): Promise<CarrierDto[]> {
|
||||
try {
|
||||
return await this.ordersService.getOrderCarriers(orderId);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar transportadoras do pedido',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('mark/:orderId')
|
||||
@ApiOperation({ summary: 'Busca marca por ID do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: 236001388 })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@ApiResponse({ status: 200, description: 'Marca encontrada com sucesso', type: MarkResponseDto })
|
||||
@ApiResponse({ status: 404, description: 'Marca não encontrada' })
|
||||
async findOrderByMark(@Param('orderId', ParseIntPipe) orderId: number): Promise<MarkResponseDto> {
|
||||
try {
|
||||
return await this.ordersService.findOrderByMark(orderId);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar marca do pedido',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('marks')
|
||||
@ApiOperation({ summary: 'Busca todas as marcas disponíveis' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@ApiResponse({ status: 200, description: 'Lista de marcas retornada com sucesso', type: [MarkResponseDto] })
|
||||
async getAllMarks(): Promise<MarkResponseDto[]> {
|
||||
try {
|
||||
return await this.ordersService.getAllMarks();
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar marcas',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('marks/search')
|
||||
@ApiOperation({ summary: 'Busca marcas por nome' })
|
||||
@ApiQuery({ name: 'name', required: true, type: 'string', description: 'Nome da marca para buscar' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@ApiResponse({ status: 200, description: 'Lista de marcas encontradas', type: [MarkResponseDto] })
|
||||
async getMarksByName(@Query('name') markName: string): Promise<MarkResponseDto[]> {
|
||||
try {
|
||||
return await this.ordersService.getMarksByName(markName);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar marcas',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('transfer-log/:orderId')
|
||||
@ApiOperation({ summary: 'Busca log de transferência por ID do pedido' })
|
||||
@ApiParam({ name: 'orderId', example: 153068638, description: 'ID do pedido para buscar log de transferência' })
|
||||
@ApiQuery({ name: 'dttransf', required: false, type: 'string', description: 'Data de transferência (formato YYYY-MM-DD)' })
|
||||
@ApiQuery({ name: 'codfilial', required: false, type: 'number', description: 'Código da filial de origem' })
|
||||
@ApiQuery({ name: 'codfilialdest', required: false, type: 'number', description: 'Código da filial de destino' })
|
||||
@ApiQuery({ name: 'numpedloja', required: false, type: 'number', description: 'Número do pedido da loja' })
|
||||
@ApiQuery({ name: 'numpedtransf', required: false, type: 'number', description: 'Número do pedido de transferência' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@ApiResponse({ status: 200, description: 'Log de transferência encontrado com sucesso', type: [EstLogTransferResponseDto] })
|
||||
@ApiResponse({ status: 400, description: 'OrderId inválido' })
|
||||
@ApiResponse({ status: 404, description: 'Log de transferência não encontrado' })
|
||||
async getTransferLog(
|
||||
@Param('orderId', ParseIntPipe) orderId: number,
|
||||
@Query('dttransf') dttransf?: string,
|
||||
@Query('codfilial') codfilial?: number,
|
||||
@Query('codfilialdest') codfilialdest?: number,
|
||||
@Query('numpedloja') numpedloja?: number,
|
||||
@Query('numpedtransf') numpedtransf?: number,
|
||||
) {
|
||||
try {
|
||||
const filters = {
|
||||
dttransf,
|
||||
codfilial,
|
||||
codfilialdest,
|
||||
numpedloja,
|
||||
numpedtransf,
|
||||
};
|
||||
|
||||
return await this.ordersService.getTransferLog(orderId, filters);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar log de transferência',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('transfer-log')
|
||||
@ApiOperation({ summary: 'Busca logs de transferência com filtros' })
|
||||
@ApiQuery({ name: 'dttransf', required: false, type: 'string', description: 'Data de transferência (formato YYYY-MM-DD)' })
|
||||
@ApiQuery({ name: 'dttransfIni', required: false, type: 'string', description: 'Data de transferência inicial (formato YYYY-MM-DD)' })
|
||||
@ApiQuery({ name: 'dttransfEnd', required: false, type: 'string', description: 'Data de transferência final (formato YYYY-MM-DD)' })
|
||||
@ApiQuery({ name: 'codfilial', required: false, type: 'number', description: 'Código da filial de origem' })
|
||||
@ApiQuery({ name: 'codfilialdest', required: false, type: 'number', description: 'Código da filial de destino' })
|
||||
@ApiQuery({ name: 'numpedloja', required: false, type: 'number', description: 'Número do pedido da loja' })
|
||||
@ApiQuery({ name: 'numpedtransf', required: false, type: 'number', description: 'Número do pedido de transferência' })
|
||||
@UsePipes(new ValidationPipe({ transform: true }))
|
||||
@ApiResponse({ status: 200, description: 'Logs de transferência encontrados com sucesso', type: [EstLogTransferResponseDto] })
|
||||
@ApiResponse({ status: 400, description: 'Filtros inválidos' })
|
||||
async getTransferLogs(
|
||||
@Query('dttransf') dttransf?: string,
|
||||
@Query('dttransfIni') dttransfIni?: string,
|
||||
@Query('dttransfEnd') dttransfEnd?: string,
|
||||
@Query('codfilial') codfilial?: number,
|
||||
@Query('codfilialdest') codfilialdest?: number,
|
||||
@Query('numpedloja') numpedloja?: number,
|
||||
@Query('numpedtransf') numpedtransf?: number,
|
||||
) {
|
||||
try {
|
||||
const filters = {
|
||||
dttransf,
|
||||
dttransfIni,
|
||||
dttransfEnd,
|
||||
codfilial,
|
||||
codfilialdest,
|
||||
numpedloja,
|
||||
numpedtransf,
|
||||
};
|
||||
|
||||
return await this.ordersService.getTransferLogs(filters);
|
||||
} catch (error) {
|
||||
throw new HttpException(
|
||||
error.message || 'Erro ao buscar logs de transferência',
|
||||
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
27
src/orders/dto/emitente.dto.ts
Normal file
27
src/orders/dto/emitente.dto.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
/**
|
||||
* DTO para dados do emitente da nota fiscal
|
||||
*/
|
||||
export class EmitenteDto {
|
||||
@ApiProperty({
|
||||
description: 'Código do emitente da nota fiscal',
|
||||
example: 32,
|
||||
nullable: true,
|
||||
})
|
||||
codEmitente: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Matrícula do funcionário emitente',
|
||||
example: 32,
|
||||
nullable: true,
|
||||
})
|
||||
emitenteMatricula: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do funcionário emitente',
|
||||
example: 'João Silva',
|
||||
nullable: true,
|
||||
})
|
||||
emitenteNome: string | null;
|
||||
}
|
||||
110
src/orders/dto/estlogtransfer.dto.ts
Normal file
110
src/orders/dto/estlogtransfer.dto.ts
Normal file
@@ -0,0 +1,110 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
/**
|
||||
* DTO para filtros do log de transferência
|
||||
*/
|
||||
export class EstLogTransferFilterDto {
|
||||
@ApiProperty({
|
||||
description: 'Data de transferência (formato YYYY-MM-DD)',
|
||||
example: '2024-02-08',
|
||||
required: false,
|
||||
})
|
||||
dttransf?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de transferência inicial (formato YYYY-MM-DD)',
|
||||
example: '2024-02-01',
|
||||
required: false,
|
||||
})
|
||||
dttransfIni?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de transferência final (formato YYYY-MM-DD)',
|
||||
example: '2024-02-15',
|
||||
required: false,
|
||||
})
|
||||
dttransfEnd?: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código da filial de origem',
|
||||
example: 6,
|
||||
required: false,
|
||||
})
|
||||
codfilial?: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código da filial de destino',
|
||||
example: 4,
|
||||
required: false,
|
||||
})
|
||||
codfilialdest?: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Número do pedido da loja',
|
||||
example: 153068638,
|
||||
required: false,
|
||||
})
|
||||
numpedloja?: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Número do pedido de transferência',
|
||||
example: 153068637,
|
||||
required: false,
|
||||
})
|
||||
numpedtransf?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* DTO para resposta do log de transferência
|
||||
*/
|
||||
export class EstLogTransferResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'Data de transferência',
|
||||
example: '2024-02-08T03:00:00.000Z',
|
||||
})
|
||||
DTTRANSF: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código da filial de origem',
|
||||
example: 6,
|
||||
})
|
||||
CODFILIAL: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código da filial de destino',
|
||||
example: 4,
|
||||
})
|
||||
CODFILIALDEST: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Número do pedido da loja',
|
||||
example: 153068638,
|
||||
})
|
||||
NUMPEDLOJA: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Número do pedido de transferência',
|
||||
example: 153068637,
|
||||
})
|
||||
NUMPEDTRANSF: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código do funcionário que fez a transferência',
|
||||
example: 158,
|
||||
})
|
||||
CODFUNCTRANSF: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Número do pedido de recebimento de transferência',
|
||||
example: null,
|
||||
nullable: true,
|
||||
})
|
||||
NUMPEDRCATRANSF: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Status da transferência',
|
||||
example: 'Em Trânsito',
|
||||
nullable: true,
|
||||
})
|
||||
statusTransfer: string | null;
|
||||
}
|
||||
113
src/orders/dto/find-orders-by-delivery-date.dto.ts
Normal file
113
src/orders/dto/find-orders-by-delivery-date.dto.ts
Normal file
@@ -0,0 +1,113 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import {
|
||||
IsOptional,
|
||||
IsDateString,
|
||||
IsString,
|
||||
IsNumber,
|
||||
IsIn,
|
||||
IsBoolean
|
||||
} from 'class-validator';
|
||||
|
||||
/**
|
||||
* DTO para buscar pedidos por data de entrega
|
||||
*/
|
||||
export class FindOrdersByDeliveryDateDto {
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Data de entrega inicial (formato: YYYY-MM-DD)',
|
||||
example: '2024-01-01'
|
||||
})
|
||||
deliveryDateIni?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Data de entrega final (formato: YYYY-MM-DD)',
|
||||
example: '2024-12-31'
|
||||
})
|
||||
deliveryDateEnd?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Código da filial',
|
||||
example: '01'
|
||||
})
|
||||
codfilial?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional({
|
||||
description: 'ID do vendedor',
|
||||
example: 123
|
||||
})
|
||||
sellerId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional({
|
||||
description: 'ID do cliente',
|
||||
example: 456
|
||||
})
|
||||
customerId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Tipo de entrega (EN, EF, RP, RI)',
|
||||
example: 'EN'
|
||||
})
|
||||
deliveryType?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Status do pedido (L, P, B, M, F)',
|
||||
example: 'L'
|
||||
})
|
||||
status?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional({
|
||||
description: 'ID do pedido específico',
|
||||
example: 236001388
|
||||
})
|
||||
orderId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Filtrar por status de transferência',
|
||||
example: 'Em Trânsito,Em Separação,Aguardando Separação,Concluída',
|
||||
enum: ['Em Trânsito', 'Em Separação', 'Aguardando Separação', 'Concluída']
|
||||
})
|
||||
statusTransfer?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional({
|
||||
description: 'ID da marca para filtrar pedidos',
|
||||
example: 1
|
||||
})
|
||||
markId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Nome da marca para filtrar pedidos',
|
||||
example: 'Nike'
|
||||
})
|
||||
markName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Boolean)
|
||||
@IsBoolean()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Filtrar pedidos que tenham registros na tabela de transfer log',
|
||||
example: true
|
||||
})
|
||||
hasPreBox?: boolean;
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
import { ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { ValidateNested } from 'class-validator';
|
||||
import { CustomerDto } from 'src/data-consult/dto/customer.dto';
|
||||
|
||||
|
||||
import {
|
||||
IsOptional,
|
||||
@@ -6,6 +10,7 @@ import {
|
||||
IsNumber,
|
||||
IsDateString,
|
||||
IsIn,
|
||||
IsBoolean
|
||||
} from 'class-validator';
|
||||
|
||||
export class FindOrdersDto {
|
||||
@@ -14,22 +19,68 @@ export class FindOrdersDto {
|
||||
@ApiPropertyOptional()
|
||||
codfilial?: string;
|
||||
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Boolean)
|
||||
@IsBoolean()
|
||||
includeCheckout?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
|
||||
filialretira?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({ description: 'ID da transportadora para filtrar pedidos' })
|
||||
carrier?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
cnpj?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional()
|
||||
hour?: number;
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional()
|
||||
minute?: number;
|
||||
|
||||
sellerId?: number;
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
partnerId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
customerName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
stockId?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional()
|
||||
|
||||
sellerId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
sellerName?: string;
|
||||
|
||||
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional()
|
||||
customerId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@@ -72,6 +123,11 @@ export class FindOrdersDto {
|
||||
@ApiPropertyOptional()
|
||||
invoiceDateEnd?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional()
|
||||
deliveryDate?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional()
|
||||
@@ -80,20 +136,86 @@ export class FindOrdersDto {
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
deliveryType?: string;
|
||||
deliveryType?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
status?: string;
|
||||
status?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional()
|
||||
type?: string;
|
||||
type?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsIn(['S', 'N'])
|
||||
@Type(() => Boolean)
|
||||
@IsBoolean()
|
||||
@ApiPropertyOptional()
|
||||
onlyPendentingTransfer?: string;
|
||||
onlyPendingTransfer?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Filtrar por status de transferência',
|
||||
example: 'Em Trânsito,Em Separação,Aguardando Separação,Concluída',
|
||||
enum: ['Em Trânsito', 'Em Separação', 'Aguardando Separação', 'Concluída']
|
||||
})
|
||||
statusTransfer?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsNumber()
|
||||
@ApiPropertyOptional({
|
||||
description: 'ID da marca para filtrar pedidos',
|
||||
})
|
||||
markId?: number;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Nome da marca para filtrar pedidos',
|
||||
|
||||
})
|
||||
markName?: string;
|
||||
|
||||
@IsOptional()
|
||||
@Type(() => Boolean)
|
||||
@IsBoolean()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Filtrar pedidos que tenham registros na tabela de transfer log',
|
||||
example: true
|
||||
})
|
||||
hasPreBox?: boolean;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Código da filial de origem da transferência (Pre-Box)',
|
||||
example: '5'
|
||||
})
|
||||
preBoxFilial?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Código da filial de destino da transferência',
|
||||
example: '6'
|
||||
})
|
||||
transferDestFilial?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Data de transferência inicial (formato YYYY-MM-DD)',
|
||||
example: '2024-01-01'
|
||||
})
|
||||
transferDateIni?: string;
|
||||
|
||||
@IsOptional()
|
||||
@IsDateString()
|
||||
@ApiPropertyOptional({
|
||||
description: 'Data de transferência final (formato YYYY-MM-DD)',
|
||||
example: '2024-12-31'
|
||||
})
|
||||
transferDateEnd?: string;
|
||||
}
|
||||
|
||||
9
src/orders/dto/leadtime.dto.ts
Normal file
9
src/orders/dto/leadtime.dto.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
export class LeadtimeDto {
|
||||
orderId: number;
|
||||
etapa: number;
|
||||
descricaoEtapa: string;
|
||||
data: Date | string;
|
||||
codigoFuncionario: number | null;
|
||||
nomeFuncionario: string | null;
|
||||
numeroPedido: number;
|
||||
}
|
||||
21
src/orders/dto/mark-response.dto.ts
Normal file
21
src/orders/dto/mark-response.dto.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class MarkResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'Nome da marca',
|
||||
example: 'Nike',
|
||||
})
|
||||
MARCA: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código da marca',
|
||||
example: 1,
|
||||
})
|
||||
CODMARCA: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Status ativo da marca (S/N)',
|
||||
example: 'S',
|
||||
})
|
||||
ATIVO: string;
|
||||
}
|
||||
23
src/orders/dto/order-delivery.dto.ts
Normal file
23
src/orders/dto/order-delivery.dto.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
|
||||
export class OrderDeliveryDto {
|
||||
storeId: number;
|
||||
createDate: Date;
|
||||
orderId: number;
|
||||
orderIdSale: number | null;
|
||||
deliveryDate: Date | null;
|
||||
cnpj: string | null;
|
||||
customerId: number;
|
||||
customer: string;
|
||||
deliveryType: string | null;
|
||||
quantityItens: number;
|
||||
status: string;
|
||||
weight: number;
|
||||
shipmentId: number;
|
||||
driverId: number | null;
|
||||
driverName: string | null;
|
||||
carPlate: string | null;
|
||||
carIdentification: string | null;
|
||||
observation: string | null;
|
||||
deliveryConfirmationDate: Date | null;
|
||||
}
|
||||
|
||||
310
src/orders/dto/order-response.dto.ts
Normal file
310
src/orders/dto/order-response.dto.ts
Normal file
@@ -0,0 +1,310 @@
|
||||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class OrderResponseDto {
|
||||
@ApiProperty({
|
||||
description: 'Data de criação do pedido',
|
||||
example: '2024-04-02T10:00:00Z',
|
||||
})
|
||||
createDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID da loja',
|
||||
example: '001 - Pre-Box (002)',
|
||||
})
|
||||
storeId: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID do pedido',
|
||||
example: 12345,
|
||||
})
|
||||
orderId: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID do cliente',
|
||||
example: '12345',
|
||||
})
|
||||
customerId: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do cliente',
|
||||
example: '12345 - João da Silva',
|
||||
})
|
||||
customerName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID do vendedor',
|
||||
example: '001',
|
||||
})
|
||||
sellerId: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do vendedor',
|
||||
example: '001 - Maria Santos',
|
||||
})
|
||||
sellerName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome da loja',
|
||||
example: 'Loja Centro',
|
||||
})
|
||||
store: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Tipo de entrega',
|
||||
example: 'Entrega (EN)',
|
||||
})
|
||||
deliveryType: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Local de entrega',
|
||||
example: '001-Centro',
|
||||
})
|
||||
deliveryLocal: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Local de entrega principal',
|
||||
example: '001-Rota Centro',
|
||||
})
|
||||
masterDeliveryLocal: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Tipo do pedido',
|
||||
example: 'TV8 - Entrega (EN)',
|
||||
})
|
||||
orderType: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Valor total do pedido',
|
||||
example: 1000.00,
|
||||
})
|
||||
amount: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de entrega',
|
||||
example: '2024-04-05T10:00:00Z',
|
||||
})
|
||||
deliveryDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Prioridade de entrega',
|
||||
example: 'Alta',
|
||||
})
|
||||
deliveryPriority: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID do carregamento',
|
||||
example: 123,
|
||||
})
|
||||
shipmentId: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de liberação',
|
||||
example: '2024-04-02T10:00:00Z',
|
||||
})
|
||||
releaseDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Usuário de liberação',
|
||||
example: '001',
|
||||
})
|
||||
releaseUser: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do usuário de liberação',
|
||||
example: '001 - João Silva',
|
||||
})
|
||||
releaseUserName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de saída do carregamento',
|
||||
example: '2024-04-03T10:00:00Z',
|
||||
})
|
||||
shipmentDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de criação do carregamento',
|
||||
example: '2024-04-02T10:00:00Z',
|
||||
})
|
||||
shipmentDateCreate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de fechamento do carregamento',
|
||||
example: '2024-04-03T18:00:00Z',
|
||||
})
|
||||
shipmentCloseDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID do plano de pagamento',
|
||||
example: '001',
|
||||
})
|
||||
paymentId: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do plano de pagamento',
|
||||
example: 'Cartão de Crédito',
|
||||
})
|
||||
paymentName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID da cobrança',
|
||||
example: '001',
|
||||
})
|
||||
billingId: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome da cobrança',
|
||||
example: '001 - Cartão de Crédito',
|
||||
})
|
||||
billingName: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de faturamento',
|
||||
example: '2024-04-02T10:00:00Z',
|
||||
})
|
||||
invoiceDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Hora de faturamento',
|
||||
example: 10,
|
||||
})
|
||||
invoiceHour: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Minuto de faturamento',
|
||||
example: 30,
|
||||
})
|
||||
invoiceMinute: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Número da nota fiscal',
|
||||
example: 123456,
|
||||
})
|
||||
invoiceNumber: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Descrição do bloqueio',
|
||||
example: 'Cliente com restrição',
|
||||
})
|
||||
BloqDescription: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Data de confirmação de entrega',
|
||||
example: '2024-04-05T15:00:00Z',
|
||||
})
|
||||
confirmDeliveryDate: Date;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Peso total',
|
||||
example: 50.5,
|
||||
})
|
||||
totalWeigth: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Processo do pedido',
|
||||
example: 3,
|
||||
})
|
||||
processOrder: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Status do pedido',
|
||||
example: 'FATURADO',
|
||||
})
|
||||
status: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Pagamento',
|
||||
example: 0,
|
||||
})
|
||||
payment: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Motorista',
|
||||
example: '001 - João Silva',
|
||||
})
|
||||
driver: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'ID do pedido de venda',
|
||||
example: 12346,
|
||||
})
|
||||
orderSaleId: number;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Descrição do carro',
|
||||
example: 'Fiat Fiorino (ABC1234)',
|
||||
})
|
||||
carDescription: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Identificação do carro',
|
||||
example: 'ABC1234',
|
||||
})
|
||||
carIdentification: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Transportadora',
|
||||
example: '001 - Transportadora XYZ',
|
||||
})
|
||||
carrier: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Status da transferência',
|
||||
example: 'Em Trânsito',
|
||||
nullable: true,
|
||||
})
|
||||
statusTransfer: string | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Loja Pre-Box',
|
||||
example: '002',
|
||||
})
|
||||
storePreBox: string;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código do emitente da nota fiscal',
|
||||
example: 32,
|
||||
nullable: true,
|
||||
})
|
||||
codEmitente: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Matrícula do funcionário emitente',
|
||||
example: 32,
|
||||
nullable: true,
|
||||
})
|
||||
emitenteMatricula: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do funcionário emitente',
|
||||
example: 'João Silva',
|
||||
nullable: true,
|
||||
})
|
||||
emitenteNome: string | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Código do funcionário de faturamento',
|
||||
example: 1336,
|
||||
nullable: true,
|
||||
})
|
||||
fatUserCode: number | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Nome do funcionário de faturamento',
|
||||
example: 'ADRIANO COSTA DA SILVA',
|
||||
nullable: true,
|
||||
})
|
||||
fatUserName: string | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Descrição completa do funcionário de faturamento',
|
||||
example: '1336-ADRIANO COSTA DA SILVA',
|
||||
nullable: true,
|
||||
})
|
||||
fatUserDescription: string | null;
|
||||
|
||||
@ApiProperty({
|
||||
description: 'Entrega agendada',
|
||||
example: 'ENTREGA NORMAL',
|
||||
})
|
||||
schedulerDelivery: string;
|
||||
}
|
||||
20
src/orders/interceptors/orders-response.interceptor.ts
Normal file
20
src/orders/interceptors/orders-response.interceptor.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import {
|
||||
CallHandler,
|
||||
ExecutionContext,
|
||||
Injectable,
|
||||
NestInterceptor,
|
||||
} from '@nestjs/common';
|
||||
import { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { ResultModel } from '../../shared/ResultModel';
|
||||
|
||||
@Injectable()
|
||||
export class OrdersResponseInterceptor<T> implements NestInterceptor<T, ResultModel<T>> {
|
||||
intercept(context: ExecutionContext, next: CallHandler<T>): Observable<ResultModel<T>> {
|
||||
return next.handle().pipe(
|
||||
map((data) => {
|
||||
return ResultModel.success(data);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
5
src/orders/interface/markdata.ts
Normal file
5
src/orders/interface/markdata.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export interface MarkData {
|
||||
MARCA: string;
|
||||
CODMARCA: number;
|
||||
ATIVO: string;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user