Alterado end point api/v1/delivery/schedule para mostrar a capacidade e saldo da capacidade com 3 casas decimais e criado peso adicional para mostrar a data de entrega na abertura da venda
This commit is contained in:
@@ -1,95 +1,95 @@
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Body, Controller, Get, HttpException, HttpStatus, Param, Post, Req } from '@nestjs/common';
|
||||
import { Cart } from 'src/domain/models/cart.model';
|
||||
import { ResultModel } from 'src/domain/models/result.model';
|
||||
import { PreOrderService } from './pre-order.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('Pre-Order')
|
||||
@Controller('api/v1/preorder')
|
||||
export class PreOrderController {
|
||||
|
||||
constructor(private readonly preOrderService: PreOrderService) { }
|
||||
|
||||
@Post('create')
|
||||
async createOrder(@Body() cart: Cart) {
|
||||
try {
|
||||
const result = await this.preOrderService.create(cart);
|
||||
return new ResultModel(true, null, result, null);
|
||||
} catch (err) {
|
||||
throw new HttpException(new ResultModel(false, err.errors.message, {}, err),
|
||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('list')
|
||||
async getPreOrders(@Req() request: any) {
|
||||
let sellerId = 0;
|
||||
let storeId = '';
|
||||
let start = new Date();
|
||||
let end = new Date();
|
||||
let idPreOrder = 0;
|
||||
let document = '';
|
||||
let nameCustomer = '';
|
||||
const query = request.query;
|
||||
if (query.store) {
|
||||
storeId = query.store;
|
||||
}
|
||||
if (query.start) {
|
||||
start = query.start;
|
||||
}
|
||||
if (query.end) {
|
||||
end = query.end;
|
||||
}
|
||||
if (query.seller) {
|
||||
sellerId = query.seller;
|
||||
}
|
||||
if (query.idPreOrder) {
|
||||
idPreOrder = query.idPreOrder;
|
||||
}
|
||||
if (query.document) {
|
||||
document = query.document;
|
||||
}
|
||||
if (query.nameCustomer) {
|
||||
nameCustomer = query.nameCustomer;
|
||||
}
|
||||
try {
|
||||
// if (sellerId == 0) {
|
||||
// throw new HttpException('Não foi informado um vendedor para a pesquisa de orçamentos.', HttpStatus.BAD_REQUEST);
|
||||
// }
|
||||
const result = await this.preOrderService.getPreOrders(sellerId, storeId, start, end, idPreOrder, document, nameCustomer);
|
||||
return new ResultModel(true, null, result, null);
|
||||
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Get('cart')
|
||||
async getCartId(@Req() request: any) {
|
||||
console.log('consultando orçamento');
|
||||
let preOrderId = 0;
|
||||
const query = request.query;
|
||||
if (query.preOrderId) {
|
||||
preOrderId = query.preOrderId;
|
||||
}
|
||||
if (preOrderId == 0) {
|
||||
throw new HttpException('Informe um número de orçamento para realizar a pesquisa.', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return await this.preOrderService.getCartId(preOrderId);
|
||||
}
|
||||
|
||||
@Get('itens/:id')
|
||||
async getItensOrder(@Param('id') preOrderId: number) {
|
||||
console.log('consultando pedido de venda');
|
||||
if (preOrderId == 0) {
|
||||
throw new HttpException('Informe um número do orçamento de venda para realizar a pesquisa.', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return await this.preOrderService.getItensPreOrder(preOrderId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*
|
||||
https://docs.nestjs.com/controllers#controllers
|
||||
*/
|
||||
|
||||
import { Body, Controller, Get, HttpException, HttpStatus, Param, Post, Req } from '@nestjs/common';
|
||||
import { Cart } from 'src/domain/models/cart.model';
|
||||
import { ResultModel } from 'src/domain/models/result.model';
|
||||
import { PreOrderService } from './pre-order.service';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('Pre-Order')
|
||||
@Controller('api/v1/preorder')
|
||||
export class PreOrderController {
|
||||
|
||||
constructor(private readonly preOrderService: PreOrderService) { }
|
||||
|
||||
@Post('create')
|
||||
async createOrder(@Body() cart: Cart) {
|
||||
try {
|
||||
const result = await this.preOrderService.create(cart);
|
||||
return new ResultModel(true, null, result, null);
|
||||
} catch (err) {
|
||||
throw new HttpException(new ResultModel(false, err.errors.message, {}, err),
|
||||
HttpStatus.INTERNAL_SERVER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('list')
|
||||
async getPreOrders(@Req() request: any) {
|
||||
let sellerId = 0;
|
||||
let storeId = '';
|
||||
let start = new Date();
|
||||
let end = new Date();
|
||||
let idPreOrder = 0;
|
||||
let document = '';
|
||||
let nameCustomer = '';
|
||||
const query = request.query;
|
||||
if (query.store) {
|
||||
storeId = query.store;
|
||||
}
|
||||
if (query.start) {
|
||||
start = query.start;
|
||||
}
|
||||
if (query.end) {
|
||||
end = query.end;
|
||||
}
|
||||
if (query.seller) {
|
||||
sellerId = query.seller;
|
||||
}
|
||||
if (query.idPreOrder) {
|
||||
idPreOrder = query.idPreOrder;
|
||||
}
|
||||
if (query.document) {
|
||||
document = query.document;
|
||||
}
|
||||
if (query.nameCustomer) {
|
||||
nameCustomer = query.nameCustomer;
|
||||
}
|
||||
try {
|
||||
// if (sellerId == 0) {
|
||||
// throw new HttpException('Não foi informado um vendedor para a pesquisa de orçamentos.', HttpStatus.BAD_REQUEST);
|
||||
// }
|
||||
const result = await this.preOrderService.getPreOrders(sellerId, storeId, start, end, idPreOrder, document, nameCustomer);
|
||||
return new ResultModel(true, null, result, null);
|
||||
|
||||
} catch (err) {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
@Get('cart')
|
||||
async getCartId(@Req() request: any) {
|
||||
console.log('consultando orçamento');
|
||||
let preOrderId = 0;
|
||||
const query = request.query;
|
||||
if (query.preOrderId) {
|
||||
preOrderId = query.preOrderId;
|
||||
}
|
||||
if (preOrderId == 0) {
|
||||
throw new HttpException('Informe um número de orçamento para realizar a pesquisa.', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return await this.preOrderService.getCartId(preOrderId);
|
||||
}
|
||||
|
||||
@Get('itens/:id')
|
||||
async getItensOrder(@Param('id') preOrderId: number) {
|
||||
console.log('consultando pedido de venda');
|
||||
if (preOrderId == 0) {
|
||||
throw new HttpException('Informe um número do orçamento de venda para realizar a pesquisa.', HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
return await this.preOrderService.getItensPreOrder(preOrderId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user