https://github.com/rsilveira65/melhor-envio-tha
Melhor Envio - Backend test
https://github.com/rsilveira65/melhor-envio-tha
docker mysql php7 phpunit symfony3
Last synced: 2 months ago
JSON representation
Melhor Envio - Backend test
- Host: GitHub
- URL: https://github.com/rsilveira65/melhor-envio-tha
- Owner: rsilveira65
- License: mit
- Created: 2018-10-04T02:38:49.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-12T13:21:08.000Z (over 6 years ago)
- Last Synced: 2025-01-23T00:11:23.796Z (4 months ago)
- Topics: docker, mysql, php7, phpunit, symfony3
- Language: PHP
- Homepage:
- Size: 168 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/rsilveira65/packer)
[](coverage)# packer
Considerando que e-commerces podem realizar a venda de uma lista de produtos que podem ser adicionados ao carrinho e que é necessário realizar o
cálculo de frete para o pedido, desenvolva uma API que calcule a partir da lista de produtos os volumes (caixas) necessárias para realizar o envio que posteriormente
serão utilizados para calcular o valor total do frete.Cada produto da lista contém:
- ID/Código identificador
- Quantidade de itens do mesmo produto
- Dimensões em centímetros (altura, largura e comprimento)
- Peso em Quilogramas, 0,35 = 350 gramasO resultado da API deverá ser uma lista de volumes com altura, largura,
comprimento em centímetros, peso em quilogramas, lista de produtos que estão em
cada caixa contendo o id do produto e quantidades de cada um. Está lista de
volumes deverá ser única por transportadora, pois os volumes finais deverão
respeitar os limites de cada.Considerações:
- Não será possível enviar volumes maiores que o limites das transportadoras,
portanto verifique os mesmos e se necessário divida os produtos em mais
volumes, caso os volumes finais sejam menores que os limites mínimos,
considere as dimensões mínimas para os volumes finais.
- Caso algum produto ultrapasse os limites da transportadora, deverá retornar
uma mensagem de aviso que não é possível realizar o envio.
- Considere fazer o melhor possível para empacotar os produtos no menor
número de volumes (caixas) possível.#### CORREIOS
| | MÍNIMO | MÁXIMO |
|-----|-----|------|
| PESO | 0 | 30 kg |
| ALTURA (A) | 2 cm | 105 cm |
| LARGURA (L) | 11 cm | 105 cm |
| COMPRIMENTO (C) | 16 cm | 105 cm |#### JADLOG
| | MÍNIMO | MÁXIMO |
|-----|-----|------|
| PESO | 0 | 150 kg |
| ALTURA (A) | 1 cm | 100 cm |
| LARGURA (L) | 1 cm | 105 cm |
| COMPRIMENTO (C) | 1 cm | 181 cm |#### VIA BRASIL
| | MÍNIMO | MÁXIMO |
|-----|-----|------|
| PESO | 0 | 200 kg |
| ALTURA (A) | 1 cm | 200 cm |
| LARGURA (L) | 1 cm | 200 cm |
| COMPRIMENTO (C) | 1 cm | 240 cm |## Getting Started
These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.
### Prerequisites
Just make sure you have [Docker](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/) properly installed.```sh
docker --version
docker-compose --version
```### Installing
```sh
cp symfony/application/app/config/parameters.yml.dist symfony/application/app/config/parameters.yml
``````sh
cp .env.dist .env
``````sh
docker-compose up -d
```Create the database schema.
```sh
docker exec application bin/console doctrine:schema:update --force
```Populate the database.
```sh
docker exec application bin/console doctrine:fixture:load -n
```Clear cache
```sh
docker exec application bin/console doctrine:cache:clear --env=prod
```## Unit Tests
Get unit test summary on executing```sh
docker exec application composer test
```## API Route
[Get the Postman collection](https://www.getpostman.com/collections/d4ae21f223d6ed7e62c7)### PackSSS
```bash
POST: http://localhost/api/pack[
{
"id": 1,
"quantity": 9,
"weight": 30,
"height": 50,
"width": 60,
"length": 50
},
{
"id": 2,
"quantity": 3,
"weight": 30,
"height": 50,
"width": 60,
"length": 50
},
{
"id": 3,
"quantity": 3,
"weight": 30,
"height": 50,
"width": 70,
"length": 50
}
]```
##### Response:
```bash
[
{
"id": 10,
"name": "Correios",
"minHeight": 2,
"maxHeight": 105,
"minWidth": 11,
"maxWidth": 105,
"minLength": 16,
"maxLength": 105,
"minWeight": 0,
"maxWeight": 30,
"amountOfPackages": 3,
"volume": 1157625,
"packages": [
{
"amountOfProducts": 7,
"volume": 1125000,
"products": [
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
}
]
},
{
"amountOfProducts": 7,
"volume": 1050000,
"products": [
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
}
]
},
{
"amountOfProducts": 1,
"volume": 150000,
"products": [
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
}
]
}
]
},
{
"id": 11,
"name": "Jadlog",
"minHeight": 1,
"maxHeight": 100,
"minWidth": 1,
"maxWidth": 105,
"minLength": 1,
"maxLength": 181,
"minWeight": 0,
"maxWeight": 150,
"amountOfPackages": 2,
"volume": 1900500,
"packages": [
{
"amountOfProducts": 12,
"volume": 1875000,
"products": [
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
}
]
},
{
"amountOfProducts": 3,
"volume": 450000,
"products": [
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
}
]
}
]
},
{
"id": 12,
"name": "Via Brasil",
"minHeight": 1,
"maxHeight": 200,
"minWidth": 1,
"maxWidth": 200,
"minLength": 1,
"maxLength": 240,
"minWeight": 0,
"maxWeight": 200,
"amountOfPackages": 1,
"volume": 9600000,
"packages": [
{
"amountOfProducts": 15,
"volume": 2325000,
"products": [
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 3,
"height": 50,
"width": 70,
"length": 50,
"weight": 30,
"volume": 175000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 2,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
},
{
"id": 1,
"height": 50,
"width": 60,
"length": 50,
"weight": 30,
"volume": 150000
}
]
}
]
}
]
```