Compare commits
8 Commits
4003aab9e0
...
homolog
| Author | SHA1 | Date | |
|---|---|---|---|
| 4975d5547d | |||
| fa6f0e0f49 | |||
| c9335a27e5 | |||
| f2b629eaad | |||
| 3b8b079123 | |||
| 1270c04a2c | |||
|
|
ca892daffa | ||
| 8e09813741 |
@@ -1,27 +1,120 @@
|
||||
name: Deploy NestJS API
|
||||
on: [push]
|
||||
name: Build (develop) / Promote (main)
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop, homolog]
|
||||
|
||||
jobs:
|
||||
build-and-push-deploy:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Login no Harbor
|
||||
- name: Free disk space
|
||||
run: |
|
||||
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login 172.35.0.216 -u ${{ secrets.HARBOR_USERNAME }} --password-stdin
|
||||
|
||||
- name: Build e Push
|
||||
df -h
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc || true
|
||||
sudo apt-get clean || true
|
||||
docker system prune -af --volumes || true
|
||||
df -h
|
||||
- name: Build (develop) / Promote (main)
|
||||
env:
|
||||
REGISTRY: harbor.jurunense.com
|
||||
DEV_PROJECT: vendaweb-dev
|
||||
PROD_PROJECT: vendaweb-prod
|
||||
IMAGE_REPO: vendaweb-api
|
||||
PROMOTE_LEGACY: 'false'
|
||||
HARBOR_USERNAME: ${{ secrets.HARBOR_USERNAME }}
|
||||
HARBOR_PASSWORD: ${{ secrets.HARBOR_PASSWORD }}
|
||||
HARBOR_DEV_USERNAME: ${{ secrets.HARBOR_DEV_USERNAME }}
|
||||
HARBOR_DEV_PASSWORD: ${{ secrets.HARBOR_DEV_PASSWORD }}
|
||||
HARBOR_PROD_USERNAME: ${{ secrets.HARBOR_PROD_USERNAME }}
|
||||
HARBOR_PROD_PASSWORD: ${{ secrets.HARBOR_PROD_PASSWORD }}
|
||||
HARBOR_LEGACY_USERNAME: ${{ secrets.HARBOR_LEGACY_USERNAME }}
|
||||
HARBOR_LEGACY_PASSWORD: ${{ secrets.HARBOR_LEGACY_PASSWORD }}
|
||||
run: |
|
||||
TAG=${{ gitea.sha }}
|
||||
docker build -t 172.35.0.216/library/vendaweb-api:$TAG .
|
||||
docker tag 172.35.0.216/library/vendaweb-api:$TAG 172.35.0.216/library/vendaweb-api:latest
|
||||
set -euo pipefail
|
||||
|
||||
docker push 172.35.0.216/library/vendaweb-api:$TAG
|
||||
docker push 172.35.0.216/library/vendaweb-api:latest
|
||||
BRANCH="${GITHUB_REF_NAME:-${GITEA_REF_NAME:-}}"
|
||||
if [ -z "$BRANCH" ] && [ -n "${GITHUB_REF:-}" ]; then
|
||||
BRANCH="${GITHUB_REF#refs/heads/}"
|
||||
fi
|
||||
|
||||
- name: Notificar Portainer via Webhook
|
||||
run: |
|
||||
# O Webhook avisa o Portainer para puxar a nova imagem imediatamente
|
||||
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_VENDAWEBAPI }}"
|
||||
DEV_IMAGE="$REGISTRY/$DEV_PROJECT/$IMAGE_REPO"
|
||||
PROD_IMAGE="$REGISTRY/$PROD_PROJECT/$IMAGE_REPO"
|
||||
LEGACY_IMAGE="$REGISTRY/library/$IMAGE_REPO"
|
||||
|
||||
DEV_USER="${HARBOR_DEV_USERNAME:-$HARBOR_USERNAME}"
|
||||
DEV_PASS="${HARBOR_DEV_PASSWORD:-$HARBOR_PASSWORD}"
|
||||
PROD_USER="${HARBOR_PROD_USERNAME:-$HARBOR_USERNAME}"
|
||||
PROD_PASS="${HARBOR_PROD_PASSWORD:-$HARBOR_PASSWORD}"
|
||||
LEGACY_USER="${HARBOR_LEGACY_USERNAME:-$PROD_USER}"
|
||||
LEGACY_PASS="${HARBOR_LEGACY_PASSWORD:-$PROD_PASS}"
|
||||
|
||||
if [ "$BRANCH" = "develop" ]; then
|
||||
TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
||||
|
||||
echo "$DEV_PASS" | docker login "$REGISTRY" -u "$DEV_USER" --password-stdin
|
||||
docker build -t "$DEV_IMAGE:$TAG" -f ./Dockerfile .
|
||||
docker push "$DEV_IMAGE:$TAG"
|
||||
docker tag "$DEV_IMAGE:$TAG" "$DEV_IMAGE:develop"
|
||||
docker push "$DEV_IMAGE:develop"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$BRANCH" = "main" ]; then
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y skopeo
|
||||
|
||||
if [ -z "${DEV_USER:-}" ] || [ -z "${DEV_PASS:-}" ]; then
|
||||
echo "Missing Harbor DEV credentials (HARBOR_DEV_USERNAME/HARBOR_DEV_PASSWORD or HARBOR_USERNAME/HARBOR_PASSWORD)." >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${PROD_USER:-}" ] || [ -z "${PROD_PASS:-}" ]; then
|
||||
echo "Missing Harbor PROD credentials (HARBOR_PROD_USERNAME/HARBOR_PROD_PASSWORD or HARBOR_USERNAME/HARBOR_PASSWORD)." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Merge commit: HEAD has 2 parents; HEAD^2 is the merged branch tip.
|
||||
PARENTS="$(git rev-list --parents -n 1 HEAD)"
|
||||
set -- $PARENTS
|
||||
SOURCE_SHA="${3:-${1:-}}"
|
||||
if [ -z "$SOURCE_SHA" ]; then
|
||||
SOURCE_SHA="${{ gitea.sha }}"
|
||||
fi
|
||||
TAG="$(echo "$SOURCE_SHA" | cut -c1-7)"
|
||||
|
||||
# Promote the exact artifact built on develop into prod (no rebuild).
|
||||
skopeo inspect --creds "$DEV_USER:$DEV_PASS" "docker://$DEV_IMAGE:$TAG" >/dev/null
|
||||
|
||||
# Validate destination repository exists and auth works.
|
||||
# Using list-tags avoids assuming a specific tag exists.
|
||||
skopeo list-tags --creds "$PROD_USER:$PROD_PASS" "docker://$PROD_IMAGE" >/dev/null
|
||||
|
||||
skopeo copy --all \
|
||||
--src-creds "$DEV_USER:$DEV_PASS" \
|
||||
--dest-creds "$PROD_USER:$PROD_PASS" \
|
||||
"docker://$DEV_IMAGE:$TAG" \
|
||||
"docker://$PROD_IMAGE:$TAG"
|
||||
|
||||
# Optional: keep legacy tags working during migration.
|
||||
if [ "${PROMOTE_LEGACY:-false}" = "true" ]; then
|
||||
skopeo copy --all \
|
||||
--src-creds "$DEV_USER:$DEV_PASS" \
|
||||
--dest-creds "$LEGACY_USER:$LEGACY_PASS" \
|
||||
"docker://$DEV_IMAGE:$TAG" \
|
||||
"docker://$LEGACY_IMAGE:$TAG"
|
||||
skopeo copy --all \
|
||||
--src-creds "$DEV_USER:$DEV_PASS" \
|
||||
--dest-creds "$LEGACY_USER:$LEGACY_PASS" \
|
||||
"docker://$DEV_IMAGE:$TAG" \
|
||||
"docker://$LEGACY_IMAGE:latest"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Unsupported branch: $BRANCH" >&2
|
||||
exit 1
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
O Rollback via Git (Mais Seguro)
|
||||
|
||||
No Gitea, faça um git revert no commit que deu erro.
|
||||
|
||||
Dê o git push.
|
||||
|
||||
O Portainer detectará a mudança e atualizará o serviço para a versão estável de forma oficial.
|
||||
76
KUBERNETES.md
Normal file
76
KUBERNETES.md
Normal file
@@ -0,0 +1,76 @@
|
||||
# Documentação do Kubernetes
|
||||
|
||||
Este documento descreve a infraestrutura e configuração do Kubernetes para o projeto **Vendaweb-api**, utilizando uma abordagem GitOps com ArgoCD e Kustomize.
|
||||
|
||||
## Estrutura de Diretórios e Arquivos
|
||||
|
||||
A configuração do Kubernetes está localizada no diretório `k8s/` e segue uma estrutura organizada para facilitar a manutenção e escalabilidade:
|
||||
|
||||
```
|
||||
k8s/
|
||||
├── argocd/ # Configurações do ArgoCD
|
||||
│ └── application-prod.yaml # Definição da Application para o ambiente de produção
|
||||
├── base/ # Recursos base do Kubernetes (Kustomize Base)
|
||||
│ ├── configmap.yaml # ConfigMap base
|
||||
│ ├── deployment.yaml # Deployment base da aplicação
|
||||
│ ├── kustomization.yaml # Arquivo principal do Kustomize Base
|
||||
│ ├── secret.yaml # Secret base
|
||||
│ └── service.yaml # Service base
|
||||
└── overlays/ # Sobrescritas para diferentes ambientes (Kustomize Overlays)
|
||||
└── prod/ # Ambiente de produção
|
||||
├── application-prod.yaml
|
||||
├── deployment-image-digest-patch.yaml
|
||||
├── kustomization.yaml
|
||||
└── service-patch.yaml
|
||||
```
|
||||
|
||||
## Recursos Base (`k8s/base`)
|
||||
|
||||
O diretório `base` contém as definições padrão dos recursos que são comuns a todos os ambientes.
|
||||
|
||||
### Deployment (`deployment.yaml`)
|
||||
|
||||
- **Nome**: `vendaweb-api`
|
||||
- **Replicas**: 15 (Configuração base)
|
||||
- **Imagem**: `172.35.0.216/library/vendaweb-api:latest`
|
||||
- **Porta do Container**: 8065
|
||||
- **Resources**:
|
||||
- Requests: CPU 100m, Memory 256Mi
|
||||
- Limits: CPU 500m, Memory 512Mi
|
||||
- **Probes**: Liveness, Readiness e Startup probes configurados no endpoint `/v1/health`.
|
||||
- **Environment**: Configurações carregadas via ConfigMap e Secret.
|
||||
|
||||
### Service (`service.yaml`)
|
||||
|
||||
- **Tipo**: ClusterIP
|
||||
- **Porta**: 8065 (TCP)
|
||||
|
||||
## Ambientes (`k8s/overlays`)
|
||||
|
||||
### Produção (`k8s/overlays/prod`)
|
||||
|
||||
A sobreposição de produção personaliza a configuração base para o ambiente produtivo.
|
||||
|
||||
- **Namespace**: `vendaweb-prod`
|
||||
- **Patches**: Aplica modificações específicas (ex: digest da imagem, configurações específicas de serviço) via `kustomization.yaml`.
|
||||
|
||||
## Deploy com ArgoCD (`k8s/argocd`)
|
||||
|
||||
O deploy é gerenciado pelo ArgoCD, que sincroniza o estado do cluster com o repositório Git.
|
||||
|
||||
### Application (`application-prod.yaml`)
|
||||
|
||||
- **Nome**: `vendaweb-api-prod`
|
||||
- **Namespace do ArgoCD**: `argocd`
|
||||
- **Origem (Source)**:
|
||||
- Repositório: `https://git.simplifiquehc.com.br/simplifique/Vendaweb-api.git`
|
||||
- Revisão: `main`
|
||||
- Path: `k8s/overlays/prod` (Aponta para o overlay de produção)
|
||||
- **Destino (Destination)**:
|
||||
- Cluster: `https://kubernetes.default.svc`
|
||||
- Namespace: `vendaweb-api` (Nota: O patch define `vendaweb-prod`, verifique a consistência)
|
||||
- **Sync Policy**: Automatizado com `selfHeal` ativado e criação automática de namespace.
|
||||
|
||||
---
|
||||
|
||||
**Observação**: Certifique-se de que as credenciais do Harbor (`imagePullSecrets`) estejam corretamente configuradas no namespace de destino para permitir o pull da imagem.
|
||||
57
WORKFLOWS.md
Normal file
57
WORKFLOWS.md
Normal file
@@ -0,0 +1,57 @@
|
||||
# Documentação dos Workflows (Gitea Actions)
|
||||
|
||||
Este documento descreve os fluxos de trabalho de integração contínua (CI) e entrega contínua (CD) configurados no Gitea Actions para o projeto **Vendaweb-api**.
|
||||
|
||||
## Visão Geral
|
||||
|
||||
Os workflows estão definidos no diretório `.gitea/workflows/`. O principal workflow configurado é o deploy da API.
|
||||
|
||||
## Workflow: Deploy NestJS API
|
||||
|
||||
**Arquivo**: `.gitea/workflows/deploy-api.yaml`
|
||||
|
||||
### Gatilhos (Triggers)
|
||||
|
||||
Este workflow é acionado automaticamente no evento:
|
||||
|
||||
- `push`: Em qualquer branch (configuração atual `on: [push]`).
|
||||
|
||||
### Jobs
|
||||
|
||||
#### `build-and-push-deploy`
|
||||
|
||||
Este job é responsável por construir a imagem Docker e enviá-la para o registry privado (Harbor).
|
||||
|
||||
- **Ambiente de Execução**: `ubuntu-latest` (Runner)
|
||||
|
||||
#### Passos (Steps):
|
||||
|
||||
1. **Checkout**
|
||||
- Utiliza `actions/checkout@v3` para clonar o código fonte do repositório.
|
||||
|
||||
2. **Login no Harbor**
|
||||
- Realiza autenticação no registry Docker privado.
|
||||
- **Registry**: `172.35.0.216`
|
||||
- **Segredos Utilizados**:
|
||||
- `HARBOR_USERNAME`: Nome de usuário do Harbor.
|
||||
- `HARBOR_PASSWORD`: Senha do usuário do Harbor.
|
||||
|
||||
3. **Build e Push**
|
||||
- Constrói a imagem Docker da aplicação.
|
||||
- Tags geradas:
|
||||
- `172.35.0.216/library/vendaweb-api:$TAG` (onde `$TAG` é o SHA do commit do Gitea `gitea.sha`)
|
||||
- `172.35.0.216/library/vendaweb-api:latest`
|
||||
- Envia ambas as tags para o registry.
|
||||
|
||||
## Variáveis e Segredos (Secrets)
|
||||
|
||||
Para que o workflow funcione corretamente, as seguintes secrets devem estar configuradas nas configurações do repositório no Gitea:
|
||||
|
||||
| Secret | Descrição |
|
||||
| ----------------- | ------------------------------------------------------------- |
|
||||
| `HARBOR_USERNAME` | Usuário com permissão de push no projeto `library` do Harbor. |
|
||||
| `HARBOR_PASSWORD` | Senha ou token de acesso do usuário do Harbor. |
|
||||
|
||||
## Integração com Kubernetes
|
||||
|
||||
Após o push da imagem com a tag `latest` (e o SHA específico), o ArgoCD (configurado conforme `KUBERNETES.md`) detectará as mudanças se houver alteração nos manifestos ou se estiver configurado para pollar a imagem `latest` (dependendo da política de `imagePullPolicy` e configuração do ArgoCD Image Updater, se houver).
|
||||
19
k8s/argocd/application-prod.yaml
Normal file
19
k8s/argocd/application-prod.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
apiVersion: argoproj.io/v1alpha1
|
||||
kind: Application
|
||||
metadata:
|
||||
name: vendaweb-api-prod
|
||||
namespace: argocd
|
||||
spec:
|
||||
project: default
|
||||
source:
|
||||
repoURL: https://git.simplifiquehc.com.br/simplifique/Vendaweb-api.git
|
||||
targetRevision: main
|
||||
path: k8s/overlays/prod
|
||||
destination:
|
||||
server: https://kubernetes.default.svc
|
||||
namespace: vendaweb-api
|
||||
syncPolicy:
|
||||
automated:
|
||||
selfHeal: true
|
||||
syncOptions:
|
||||
- CreateNamespace=true
|
||||
10
k8s/base/configmap.yaml
Normal file
10
k8s/base/configmap.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: vendaweb-api-config
|
||||
data:
|
||||
REDIS_HOST: '172.35.0.250'
|
||||
REDIS_PORT: '6379'
|
||||
DB_HOST: '172.35.0.250'
|
||||
DB_PORT: '1521'
|
||||
DB_SERVICE_NAME: 'ORCL'
|
||||
62
k8s/base/deployment.yaml
Normal file
62
k8s/base/deployment.yaml
Normal file
@@ -0,0 +1,62 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
labels:
|
||||
app: vendaweb-api
|
||||
spec:
|
||||
replicas: 15
|
||||
selector:
|
||||
matchLabels:
|
||||
app: vendaweb-api
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: vendaweb-api
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: harbor-secret
|
||||
containers:
|
||||
- name: api
|
||||
image: 172.35.0.216/library/vendaweb-api:latest
|
||||
imagePullPolicy: IfNotPresent
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: 8067
|
||||
protocol: TCP
|
||||
envFrom:
|
||||
- configMapRef:
|
||||
name: vendaweb-api-config
|
||||
- secretRef:
|
||||
name: vendaweb-api-secrets
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /v1/health
|
||||
port: http
|
||||
initialDelaySeconds: 20
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 6
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /v1/health
|
||||
port: http
|
||||
initialDelaySeconds: 10
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 6
|
||||
startupProbe:
|
||||
httpGet:
|
||||
path: /v1/health
|
||||
port: http
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 24
|
||||
resources:
|
||||
requests:
|
||||
cpu: 100m
|
||||
memory: 256Mi
|
||||
limits:
|
||||
cpu: 500m
|
||||
memory: 512Mi
|
||||
7
k8s/base/kustomization.yaml
Normal file
7
k8s/base/kustomization.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- configmap.yaml
|
||||
8
k8s/base/secret.yaml
Normal file
8
k8s/base/secret.yaml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: vendaweb-api-secrets
|
||||
type: Opaque
|
||||
stringData:
|
||||
DB_USERNAME: 'simplifique'
|
||||
DB_PASSWORD: 'simplifique'
|
||||
15
k8s/base/service.yaml
Normal file
15
k8s/base/service.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
labels:
|
||||
app: vendaweb-api
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: vendaweb-api
|
||||
ports:
|
||||
- name: http
|
||||
port: 8067
|
||||
targetPort: 8067
|
||||
protocol: TCP
|
||||
10
k8s/overlays/prod/deployment-image-digest-patch.yaml
Normal file
10
k8s/overlays/prod/deployment-image-digest-patch.yaml
Normal file
@@ -0,0 +1,10 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
spec:
|
||||
template:
|
||||
spec:
|
||||
containers:
|
||||
- name: api
|
||||
image: 172.35.0.216/library/vendaweb-api@sha256:aac490fcb4ef7baa95f1df01fa50d2d44bdb4ed12b235e5dd89e1d7dc3cd0a3a
|
||||
11
k8s/overlays/prod/kustomization.yaml
Normal file
11
k8s/overlays/prod/kustomization.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||
kind: Kustomization
|
||||
|
||||
namespace: vendaweb-prod
|
||||
|
||||
resources:
|
||||
- ../../base
|
||||
|
||||
patches:
|
||||
- path: deployment-image-digest-patch.yaml
|
||||
- path: service-patch.yaml
|
||||
11
k8s/overlays/prod/service-patch.yaml
Normal file
11
k8s/overlays/prod/service-patch.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: vendaweb-api
|
||||
spec:
|
||||
type: NodePort
|
||||
ports:
|
||||
- name: http
|
||||
port: 8067
|
||||
targetPort: 8067
|
||||
nodePort: 30001
|
||||
@@ -16,10 +16,10 @@ async function bootstrap() {
|
||||
do cadastro de parceiros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`)
|
||||
.setVersion("2023.1.2")
|
||||
.addTag("VendaWeb")
|
||||
.addTag("Autenticação")
|
||||
.addTag("Auth")
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, options);
|
||||
SwaggerModule.setup("docs", app, document);
|
||||
await app.listen(8065);
|
||||
await app.listen(8066);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
@@ -1448,7 +1448,7 @@ export class SalesService {
|
||||
const queryRunner = connectionDb.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
/*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
|
||||
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
||||
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
||||
@@ -1462,7 +1462,22 @@ export class SalesService {
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
||||
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
||||
' ORDER BY VLFRETE';
|
||||
' ORDER BY VLFRETE';*/
|
||||
|
||||
const sql = `SELECT 0 as "id"
|
||||
,'1' as "store"
|
||||
,ESVCALCULOFRETE.CODCIDADE as "cityId"
|
||||
,PCCIDADE.NOMECIDADE as "cityName"
|
||||
,NULL as "carrierId"
|
||||
,'SIMPLIFIQUE HOMECENTER' as "carrierName"
|
||||
,0 as "minSale"
|
||||
,ESVCALCULOFRETE.VLFRETE as "deliveryValue"
|
||||
,NULL as "deliveryTime"
|
||||
FROM ESVCALCULOFRETE, PCCIDADE
|
||||
WHERE ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE
|
||||
AND ESVCALCULOFRETE.CODCIDADE = :1
|
||||
AND ESVCALCULOFRETE.IDCART = :2
|
||||
ORDER BY VLFRETE`;
|
||||
|
||||
const deliveryTaxTable = await queryRunner.manager
|
||||
.query(sql, [cityId, cartId]);
|
||||
@@ -1514,7 +1529,22 @@ export class SalesService {
|
||||
const queryRunner = connectionDb.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
const sql = `SELECT 0 as "id"
|
||||
,'1' as "store"
|
||||
,ESVCALCULOFRETE.CODCIDADE as "cityId"
|
||||
,PCCIDADE.NOMECIDADE as "cityName"
|
||||
,NULL as "carrierId"
|
||||
,'SIMPLIFIQUE HOMECENTER' as "carrierName"
|
||||
,0 as "minSale"
|
||||
,ESVCALCULOFRETE.VLFRETE as "deliveryValue"
|
||||
,NULL as "deliveryTime"
|
||||
FROM ESVCALCULOFRETE, PCCIDADE
|
||||
WHERE ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE
|
||||
AND ESVCALCULOFRETE.CODCIDADE = :1
|
||||
AND ESVCALCULOFRETE.IDCART = :2
|
||||
ORDER BY VLFRETE`;
|
||||
|
||||
/*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
|
||||
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
||||
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
||||
@@ -1528,7 +1558,7 @@ export class SalesService {
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
||||
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
||||
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
||||
' ORDER BY VLFRETE';
|
||||
' ORDER BY VLFRETE';*/
|
||||
|
||||
let deliveryTaxTable = await queryRunner.manager
|
||||
.query(sql, [dataDeliveryTax.cityId, dataDeliveryTax.cartId]);
|
||||
|
||||
Reference in New Issue
Block a user