Compare commits
49 Commits
6dba6fb1a9
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
16882046cf | ||
| fd17be5408 | |||
|
|
ecd298442b | ||
| 589fa2913c | |||
| 587d097d9b | |||
| a694af97c6 | |||
| 6523c5f520 | |||
| 0c09ee795e | |||
| 09396e334d | |||
| 605d68b4b0 | |||
| c707d4a065 | |||
| 0b28379145 | |||
| ca43de8756 | |||
| bb21ca33e4 | |||
| 48d6e64ada | |||
| e0731db836 | |||
| d2265390bd | |||
| a34c7c415c | |||
| 4975d5547d | |||
| fa6f0e0f49 | |||
| c9335a27e5 | |||
| f2b629eaad | |||
| 3b8b079123 | |||
| 1270c04a2c | |||
|
|
ca892daffa | ||
| 8e09813741 | |||
| 4003aab9e0 | |||
|
|
6c1599fbaa | ||
|
|
2b9868bf6d | ||
| 90366c21e5 | |||
| bda9f0f13b | |||
| ce988e93b1 | |||
| 19d34ea672 | |||
| 91f3e857a0 | |||
| e2a008e9a9 | |||
| a3021a545c | |||
| 2ff13691b0 | |||
| f9ba12c43f | |||
| 699a9191e2 | |||
| d400a3febb | |||
| e1159acdf0 | |||
| dfd6c0ef8a | |||
| 7a9a40e859 | |||
| 395c6de2c6 | |||
|
|
6a2e16e503 | ||
|
|
615c4353b8 | ||
|
|
19e1317e3a | ||
|
|
f32a3fd40f | ||
|
|
b1aae3304b |
13
.env
Normal file
13
.env
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
ORACLE_CLIENT_PATH='/usr/lib/oracle/21/client64/lib'
|
||||||
|
|
||||||
|
|
||||||
|
###REDIS
|
||||||
|
REDIS_HOST='172.35.0.217'
|
||||||
|
REDIS_PORT='6379'
|
||||||
|
|
||||||
|
|
||||||
|
####ORACLE
|
||||||
|
PORT='8065'
|
||||||
|
DB_USERNAME='simplifique'
|
||||||
|
DB_PASSWORD='simplifique'
|
||||||
|
DB_CONNECT_STRING='(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.35.0.250)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)))'
|
||||||
41
.gitea/workflows/deploy-api.yaml
Normal file
41
.gitea/workflows/deploy-api.yaml
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
name: Build (develop) / Promote (main)
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [main]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Build and Push
|
||||||
|
run: |
|
||||||
|
REGISTRY="git.simplifiquehc.com.br"
|
||||||
|
IMAGE_NAME="$REGISTRY/simplifique/vendaweb-api"
|
||||||
|
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
||||||
|
|
||||||
|
echo "${{ secrets.K8S }}" | docker login "$REGISTRY" -u "${{ gitea.actor }}" --password-stdin
|
||||||
|
|
||||||
|
docker build -t "$IMAGE_NAME:$SHA_TAG" -t "$IMAGE_NAME:latest" .
|
||||||
|
docker push "$IMAGE_NAME:$SHA_TAG"
|
||||||
|
docker push "$IMAGE_NAME:latest"
|
||||||
|
|
||||||
|
- name: Update Manifest and Push to Git
|
||||||
|
run: |
|
||||||
|
SHA_TAG=$(echo ${{ gitea.sha }} | cut -c1-7)
|
||||||
|
IMAGE_NAME="git.simplifiquehc.com.br/simplifique/vendaweb-api"
|
||||||
|
|
||||||
|
MANIFEST_FILE="k8s/overlays/prod/deployment-image-digest-patch.yaml"
|
||||||
|
|
||||||
|
sed -i "s|image: $IMAGE_NAME:.*|image: $IMAGE_NAME:$SHA_TAG|g" "$MANIFEST_FILE"
|
||||||
|
|
||||||
|
git config user.name "Gitea Action"
|
||||||
|
git config user.email "actions@simplifiquehc.com.br"
|
||||||
|
|
||||||
|
git add "$MANIFEST_FILE"
|
||||||
|
git commit -m "chore: update image tag to $SHA_TAG [skip ci]"
|
||||||
|
git push origin main
|
||||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -33,3 +33,6 @@ lerna-debug.log*
|
|||||||
!.vscode/launch.json
|
!.vscode/launch.json
|
||||||
!.vscode/extensions.json
|
!.vscode/extensions.json
|
||||||
|
|
||||||
|
# Environment variables
|
||||||
|
.env
|
||||||
|
|
||||||
|
|||||||
67
Dockerfile
67
Dockerfile
@@ -1,32 +1,55 @@
|
|||||||
FROM node:16
|
ARG NODE_VERSION=16.20
|
||||||
|
ARG DEBIAN_VARIANT=bullseye
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y \
|
|
||||||
apt-transport-https \
|
|
||||||
ca-certificates \
|
|
||||||
libaio1 \
|
|
||||||
unzip \
|
|
||||||
wget \
|
|
||||||
libc6 \
|
|
||||||
libncurses5 && \
|
|
||||||
mkdir -p /opt/oracle && \
|
|
||||||
wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip -O /opt/oracle/instantclient-basic-linuxx64.zip && \
|
|
||||||
unzip /opt/oracle/instantclient-basic-linuxx64.zip -d /opt/oracle && \
|
|
||||||
rm /opt/oracle/instantclient-basic-linuxx64.zip && \
|
|
||||||
ln -s /opt/oracle/instantclient_* /opt/oracle/instantclient && \
|
|
||||||
echo "/opt/oracle/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf && \
|
|
||||||
ldconfig
|
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-${DEBIAN_VARIANT} AS builder
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ARG INSTANTCLIENT_ZIP_URL=https://download.oracle.com/otn_software/linux/instantclient/instantclient-basiclite-linuxx64.zip
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends ca-certificates wget unzip libaio1 libnsl2 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/* \
|
||||||
|
&& mkdir -p /opt/oracle \
|
||||||
|
&& wget -q "${INSTANTCLIENT_ZIP_URL}" -O /opt/oracle/instantclient.zip \
|
||||||
|
&& unzip -q /opt/oracle/instantclient.zip -d /opt/oracle \
|
||||||
|
&& rm /opt/oracle/instantclient.zip \
|
||||||
|
&& rm -f /opt/oracle/instantclient_*/ojdbc*.jar \
|
||||||
|
/opt/oracle/instantclient_*/ucp*.jar \
|
||||||
|
/opt/oracle/instantclient_*/xstreams.jar \
|
||||||
|
/opt/oracle/instantclient_*/adrci \
|
||||||
|
/opt/oracle/instantclient_*/genezi \
|
||||||
|
/opt/oracle/instantclient_*/uidrvci \
|
||||||
|
&& ln -s "$(ls -d /opt/oracle/instantclient_* | head -n 1)" /opt/oracle/instantclient
|
||||||
|
|
||||||
|
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
||||||
|
ENV PATH=/opt/oracle/instantclient:$PATH
|
||||||
|
|
||||||
COPY package*.json ./
|
COPY package*.json ./
|
||||||
|
ENV NPM_CONFIG_LEGACY_PEER_DEPS=true
|
||||||
|
RUN npm ci
|
||||||
RUN npm install --legacy-peer-deps
|
|
||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
RUN npm run build \
|
||||||
|
&& npm prune --omit=dev --legacy-peer-deps \
|
||||||
|
&& npm cache clean --force
|
||||||
|
|
||||||
|
FROM node:${NODE_VERSION}-${DEBIAN_VARIANT}-slim AS runtime
|
||||||
|
|
||||||
CMD ["npm", "run", "start:prod"]
|
WORKDIR /app
|
||||||
|
|
||||||
|
ENV NODE_ENV=production
|
||||||
|
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
||||||
|
ENV PATH=/opt/oracle/instantclient:$PATH
|
||||||
|
|
||||||
|
RUN apt-get update \
|
||||||
|
&& apt-get install -y --no-install-recommends libaio1 libnsl2 \
|
||||||
|
&& rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
COPY --from=builder /opt/oracle /opt/oracle
|
||||||
|
COPY --from=builder /app/package*.json ./
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
|
||||||
|
EXPOSE 8065
|
||||||
|
|
||||||
|
CMD ["node", "dist/main"]
|
||||||
|
|||||||
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**: 3 (Base) / 15 (Produção via overlay)
|
||||||
|
- **Imagem**: `git.simplifiquehc.com.br/simplifique/vendaweb-api:<sha>`
|
||||||
|
- **Porta do Container**: 8067
|
||||||
|
- **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: tag da imagem, NodePort do service, replicas) 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-prod`
|
||||||
|
- **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.
|
||||||
60
WORKFLOWS.md
Normal file
60
WORKFLOWS.md
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
# 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`: Na branch `main`.
|
||||||
|
|
||||||
|
### 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:
|
||||||
|
- `git.simplifiquehc.com.br/simplifique/vendaweb-api:$TAG` (onde `$TAG` é o SHA curto do commit)
|
||||||
|
- `git.simplifiquehc.com.br/simplifique/vendaweb-api:latest`
|
||||||
|
- Envia ambas as tags para o registry.
|
||||||
|
|
||||||
|
4. **Atualizar Manifest e Push no Git**
|
||||||
|
- Atualiza `k8s/overlays/prod/deployment-image-digest-patch.yaml` para apontar para a tag `$TAG`.
|
||||||
|
|
||||||
|
## 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).
|
||||||
@@ -1,14 +1,18 @@
|
|||||||
version: '3.8'
|
version: '3.8'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
vendaweb:
|
vendaweb-api:
|
||||||
image: link70/vendaweb
|
image: 172.35.0.216/library/vendaweb-api:latest
|
||||||
deploy:
|
|
||||||
replicas: 20
|
|
||||||
resources:
|
|
||||||
limits:
|
|
||||||
cpus: '0.5'
|
|
||||||
memory: 512M
|
|
||||||
ports:
|
ports:
|
||||||
- "8065:8065"
|
- "8065:8065"
|
||||||
restart: always
|
networks:
|
||||||
|
- simplifique-network
|
||||||
|
deploy:
|
||||||
|
replicas: 4
|
||||||
|
update_config:
|
||||||
|
order: start-first
|
||||||
|
parallelism: 1
|
||||||
|
|
||||||
|
networks:
|
||||||
|
simplifique-network:
|
||||||
|
external: true
|
||||||
27
k8s/argocd/application-prod.yaml
Normal file
27
k8s/argocd/application-prod.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
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-prod
|
||||||
|
syncPolicy:
|
||||||
|
automated:
|
||||||
|
selfHeal: true
|
||||||
|
prune: true
|
||||||
|
retry:
|
||||||
|
limit: 2
|
||||||
|
backoff:
|
||||||
|
duration: 5s
|
||||||
|
factor: 2
|
||||||
|
maxDuration: 3m
|
||||||
|
syncOptions:
|
||||||
|
- CreateNamespace=true
|
||||||
|
- PruneLast=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'
|
||||||
71
k8s/base/deployment.yaml
Normal file
71
k8s/base/deployment.yaml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: vendaweb-api
|
||||||
|
labels:
|
||||||
|
app: vendaweb-api
|
||||||
|
spec:
|
||||||
|
replicas: 3
|
||||||
|
revisionHistoryLimit: 5
|
||||||
|
minReadySeconds: 10
|
||||||
|
progressDeadlineSeconds: 600
|
||||||
|
strategy:
|
||||||
|
type: RollingUpdate
|
||||||
|
rollingUpdate:
|
||||||
|
maxSurge: 1
|
||||||
|
maxUnavailable: 0
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: vendaweb-api
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: vendaweb-api
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: gitea-auth
|
||||||
|
terminationGracePeriodSeconds: 30
|
||||||
|
containers:
|
||||||
|
- name: api
|
||||||
|
image: git.simplifiquehc.com.br/simplifique/vendaweb-api:589fa29
|
||||||
|
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: git.simplifiquehc.com.br/simplifique/vendaweb-api:fd17be5
|
||||||
6
k8s/overlays/prod/deployment-prod-patch.yaml
Normal file
6
k8s/overlays/prod/deployment-prod-patch.yaml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: vendaweb-api
|
||||||
|
spec:
|
||||||
|
replicas: 15
|
||||||
12
k8s/overlays/prod/kustomization.yaml
Normal file
12
k8s/overlays/prod/kustomization.yaml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
|
||||||
|
namespace: vendaweb-prod
|
||||||
|
|
||||||
|
resources:
|
||||||
|
- ../../base
|
||||||
|
|
||||||
|
patches:
|
||||||
|
- path: service-patch.yaml
|
||||||
|
- path: deployment-prod-patch.yaml
|
||||||
|
- path: deployment-image-digest-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
|
||||||
@@ -93,7 +93,7 @@ export class UserService {
|
|||||||
' WHERE PCEMPR.CODFILIAL = PCFILIAL.CODIGO (+)' +
|
' WHERE PCEMPR.CODFILIAL = PCFILIAL.CODIGO (+)' +
|
||||||
' AND PCPARAMFILIAL.CODFILIAL = \'99\' ' +
|
' AND PCPARAMFILIAL.CODFILIAL = \'99\' ' +
|
||||||
' AND PCPARAMFILIAL.NOME = \'CON_CODSETORGERENTELOJA\' ' +
|
' AND PCPARAMFILIAL.NOME = \'CON_CODSETORGERENTELOJA\' ' +
|
||||||
' AND PCEMPR.EMAIL = :username AND PCEMPR.SENHABD = CRYPT(:password, USUARIOBD)';
|
' AND PCEMPR.USUARIOBD = :username AND PCEMPR.SENHABD = CRYPT(:password, USUARIOBD)';
|
||||||
|
|
||||||
const users = await queryRunner.manager
|
const users = await queryRunner.manager
|
||||||
.query(sql, [user.email, user.password]);
|
.query(sql, [user.email, user.password]);
|
||||||
@@ -142,7 +142,7 @@ export class UserService {
|
|||||||
.query(sqlDiasSemEntrega, [Number.parseInt(users[0].deliveryTime)]);
|
.query(sqlDiasSemEntrega, [Number.parseInt(users[0].deliveryTime)]);
|
||||||
|
|
||||||
const days = Number.parseInt(deliveryDays2[0].days) +
|
const days = Number.parseInt(deliveryDays2[0].days) +
|
||||||
( noDeliveryDays.length > 0 ? Number.parseInt(noDeliveryDays[0].daysNoDelivery) : 0 );
|
(noDeliveryDays.length > 0 ? Number.parseInt(noDeliveryDays[0].daysNoDelivery) : 0);
|
||||||
|
|
||||||
const userDb = users[0];
|
const userDb = users[0];
|
||||||
console.log(userDb);
|
console.log(userDb);
|
||||||
|
|||||||
@@ -12,9 +12,9 @@ export class AppController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Get('health')
|
@Get('health')
|
||||||
@ApiOperation({ summary: 'Health check' })
|
@ApiOperation({ summary: 'Health check' })
|
||||||
healthCheck() {
|
healthCheck() {
|
||||||
return { status: 'ok' };
|
return { status: 'SIMPLIFIQUE HOME CENTER 202' };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
import { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
||||||
import { ConnectionOptions } from 'typeorm';
|
import { ConnectionOptions } from 'typeorm';
|
||||||
|
import 'dotenv/config';
|
||||||
|
|
||||||
export const typeOrmConfig: TypeOrmModuleOptions = {
|
export const typeOrmConfig: TypeOrmModuleOptions = {
|
||||||
type: "oracle",
|
type: "oracle",
|
||||||
// host: "192.168.100.40",
|
host: "172.35.0.250",
|
||||||
// username: "LIVIA",
|
username: process.env.DB_USERNAME || "simplifique",
|
||||||
// password: "LIVIA",
|
password: process.env.DB_PASSWORD || "simplifique",
|
||||||
host: "10.1.1.241",
|
connectString:
|
||||||
username: "SEVEN",
|
process.env.DB_CONNECT_STRING ||
|
||||||
password: "USR54SEV",
|
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.35.0.250)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)))',
|
||||||
// username: "API",
|
|
||||||
// password: "E05H5KIEQV3YKDJR",
|
|
||||||
port: 1521,
|
port: 1521,
|
||||||
sid: "WINT",
|
sid: "ORCL",
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||||
@@ -21,11 +20,14 @@ export const typeOrmConfig: TypeOrmModuleOptions = {
|
|||||||
|
|
||||||
export const connectionOptions: ConnectionOptions = {
|
export const connectionOptions: ConnectionOptions = {
|
||||||
type: "oracle",
|
type: "oracle",
|
||||||
host: "10.1.1.241",
|
host: "172.35.0.250",
|
||||||
username: "SEVEN",
|
username: process.env.DB_USERNAME || "simplifique",
|
||||||
password: "USR54SEV",
|
password: process.env.DB_PASSWORD || "simplifique",
|
||||||
|
connectString:
|
||||||
|
process.env.DB_CONNECT_STRING ||
|
||||||
|
'(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.35.0.250)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)))',
|
||||||
port: 1521,
|
port: 1521,
|
||||||
sid: "WINT",
|
sid: "ORCL",
|
||||||
synchronize: false,
|
synchronize: false,
|
||||||
logging: false,
|
logging: false,
|
||||||
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
entities: [__dirname + '/../**/*.entity.{js,ts}'],
|
||||||
|
|||||||
@@ -1355,7 +1355,7 @@ export class Pcclient {
|
|||||||
@Column({ name: 'ORGAOPUBMUNICIPAL' })
|
@Column({ name: 'ORGAOPUBMUNICIPAL' })
|
||||||
orgaopubmunicipal: string;
|
orgaopubmunicipal: string;
|
||||||
|
|
||||||
@Column({ name: 'CODCIDADECOM' })
|
@Column({ name: 'CODCIDADECOM' })
|
||||||
codcidadecom: number;
|
codcidadecom: number;
|
||||||
|
|
||||||
@Column({ name: 'CODPROMOCAOMED' })
|
@Column({ name: 'CODPROMOCAOMED' })
|
||||||
@@ -1622,8 +1622,8 @@ export class Pcclient {
|
|||||||
@Column({ name: 'CODCONDCOMERCIAL' })
|
@Column({ name: 'CODCONDCOMERCIAL' })
|
||||||
codcondcomercial: string;
|
codcondcomercial: string;
|
||||||
|
|
||||||
@Column({ name: 'MEIOCOMUNICACAO' })
|
// @Column({ name: 'MEIOCOMUNICACAO' })
|
||||||
meiocomunicacao: string;
|
// meiocomunicacao: string;
|
||||||
|
|
||||||
@Column({ name: 'CODGRUPOCOMERCIALMED' })
|
@Column({ name: 'CODGRUPOCOMERCIALMED' })
|
||||||
codgrupocomercialmed: number;
|
codgrupocomercialmed: number;
|
||||||
|
|||||||
@@ -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.`)
|
do cadastro de parceiros, consulta de venda de movimentação e pagamentos, e fechamento das comissões dos parceiros.`)
|
||||||
.setVersion("2023.1.2")
|
.setVersion("2023.1.2")
|
||||||
.addTag("VendaWeb")
|
.addTag("VendaWeb")
|
||||||
.addTag("Autenticação")
|
.addTag("Auth")
|
||||||
.build();
|
.build();
|
||||||
const document = SwaggerModule.createDocument(app, options);
|
const document = SwaggerModule.createDocument(app, options);
|
||||||
SwaggerModule.setup("docs", app, document);
|
SwaggerModule.setup("docs", app, document);
|
||||||
await app.listen(8065);
|
await app.listen(8067);
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
import { Provider } from '@nestjs/common';
|
import { Provider } from '@nestjs/common';
|
||||||
|
|
||||||
import Redis = require('ioredis');
|
import Redis = require('ioredis');
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const redisProvider: Provider = {
|
export const redisProvider: Provider = {
|
||||||
|
|
||||||
provide: 'REDIS_CLIENT',
|
provide: 'REDIS_CLIENT',
|
||||||
|
|
||||||
useFactory: () => {
|
useFactory: () => {
|
||||||
|
|
||||||
return new Redis({
|
return new Redis({
|
||||||
host: '10.1.1.109',
|
|
||||||
|
host: '172.35.0.217',
|
||||||
|
|
||||||
port: 6379,
|
port: 6379,
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
@@ -44,7 +44,7 @@ export class CustomerService {
|
|||||||
' ,pccidade.codibge as "ibgeCode" ' +
|
' ,pccidade.codibge as "ibgeCode" ' +
|
||||||
' ,pcclient.dtnasc as "birthdate" ' +
|
' ,pcclient.dtnasc as "birthdate" ' +
|
||||||
' ,pcclient.codatv1 as "ramoId" ' +
|
' ,pcclient.codatv1 as "ramoId" ' +
|
||||||
' ,pcclient.meiocomunicacao as "communicate" ' +
|
// ' ,pcclient.meiocomunicacao as "communicate" ' +
|
||||||
' ,pcclient.latitude as "latitude" ' +
|
' ,pcclient.latitude as "latitude" ' +
|
||||||
' ,pcclient.longitude as "longitude" ' +
|
' ,pcclient.longitude as "longitude" ' +
|
||||||
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
||||||
@@ -102,14 +102,14 @@ export class CustomerService {
|
|||||||
' ,pcclient.telent as "phone" ' +
|
' ,pcclient.telent as "phone" ' +
|
||||||
' ,pcclient.telcelent as "cellPhone" ' +
|
' ,pcclient.telcelent as "cellPhone" ' +
|
||||||
' ,pcclient.ieent as "numberState" ' +
|
' ,pcclient.ieent as "numberState" ' +
|
||||||
' ,pcclient.codcategoria as "categoryId" ' +
|
// ' ,pcclient.codcategoria as "categoryId" ' +
|
||||||
' ,pcclient.codsubcategoria as "subCategoryId" ' +
|
// ' ,pcclient.codsubcategoria as "subCategoryId" ' +
|
||||||
' ,pcclient.codpraca as "placeId" ' +
|
' ,pcclient.codpraca as "placeId" ' +
|
||||||
' ,pcclient.codusur1 as "sellerId" ' +
|
' ,pcclient.codusur1 as "sellerId" ' +
|
||||||
' ,pccidade.codibge as "ibgeCode" ' +
|
' ,pccidade.codibge as "ibgeCode" ' +
|
||||||
' ,pcclient.dtnasc as "birthdate" ' +
|
' ,pcclient.dtnasc as "birthdate" ' +
|
||||||
' ,pcclient.codatv1 as "ramoId" ' +
|
' ,pcclient.codatv1 as "ramoId" ' +
|
||||||
' ,pcclient.meiocomunicacao as "communicate" ' +
|
// ' ,pcclient.meiocomunicacao as "communicate" ' +
|
||||||
' ,pcclient.latitude as "latitude" ' +
|
' ,pcclient.latitude as "latitude" ' +
|
||||||
' ,pcclient.longitude as "longitude" ' +
|
' ,pcclient.longitude as "longitude" ' +
|
||||||
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
||||||
@@ -158,7 +158,7 @@ export class CustomerService {
|
|||||||
' ,pccidade.codibge as "ibgeCode" ' +
|
' ,pccidade.codibge as "ibgeCode" ' +
|
||||||
' ,pcclient.dtnasc as "birthdate" ' +
|
' ,pcclient.dtnasc as "birthdate" ' +
|
||||||
' ,pcclient.codatv1 as "ramoId" ' +
|
' ,pcclient.codatv1 as "ramoId" ' +
|
||||||
' ,pcclient.meiocomunicacao as "communicate" ' +
|
//' ,pcclient.meiocomunicacao as "communicate" ' +
|
||||||
' ,pcclient.latitude as "latitude" ' +
|
' ,pcclient.latitude as "latitude" ' +
|
||||||
' ,pcclient.longitude as "longitude" ' +
|
' ,pcclient.longitude as "longitude" ' +
|
||||||
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
||||||
@@ -173,7 +173,7 @@ export class CustomerService {
|
|||||||
FROM PCPRACA
|
FROM PCPRACA
|
||||||
WHERE PCPRACA.CODPRACA = ${customer[0].placeId}`);
|
WHERE PCPRACA.CODPRACA = ${customer[0].placeId}`);
|
||||||
|
|
||||||
return {...customer[0], place: place[0]};
|
return { ...customer[0], place: place[0] };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
throw error;
|
throw error;
|
||||||
@@ -267,16 +267,16 @@ export class CustomerService {
|
|||||||
newCustomer.telcelent = customer.cellPhone;
|
newCustomer.telcelent = customer.cellPhone;
|
||||||
newCustomer.celularwhatsapp = customer.cellPhone;
|
newCustomer.celularwhatsapp = customer.cellPhone;
|
||||||
newCustomer.codusur1 = customer.sellerId;
|
newCustomer.codusur1 = customer.sellerId;
|
||||||
newCustomer.codatv1 = ( customer.ramo != null && customer.ramo.id > 0 ) ? customer.ramo.id : newCustomer.codatv1;
|
newCustomer.codatv1 = (customer.ramo != null && customer.ramo.id > 0) ? customer.ramo.id : newCustomer.codatv1;
|
||||||
//Endereço de entrega
|
//Endereço de entrega
|
||||||
newCustomer.cepent = customer.zipCode;
|
newCustomer.cepent = customer.zipCode;
|
||||||
newCustomer.enderent = customer.address.toUpperCase();
|
newCustomer.enderent = customer.address.toUpperCase();
|
||||||
newCustomer.numeroent = customer.addressNumber;
|
newCustomer.numeroent = customer.addressNumber;
|
||||||
if ( customer.complement !== null && customer.complement.length > 80 ) {
|
if (customer.complement !== null && customer.complement.length > 80) {
|
||||||
newCustomer.complementoent = customer.complement.substring(0, 80 ).toUpperCase();
|
newCustomer.complementoent = customer.complement.substring(0, 80).toUpperCase();
|
||||||
} else {
|
} else {
|
||||||
if ( customer.complement != null ) {
|
if (customer.complement != null) {
|
||||||
newCustomer.complementoent = customer.complement.toUpperCase();
|
newCustomer.complementoent = customer.complement.toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newCustomer.bairroent = customer.neighborhood.toUpperCase();
|
newCustomer.bairroent = customer.neighborhood.toUpperCase();
|
||||||
@@ -286,10 +286,10 @@ export class CustomerService {
|
|||||||
newCustomer.cepcom = customer.zipCode;
|
newCustomer.cepcom = customer.zipCode;
|
||||||
newCustomer.endercom = customer.address.toUpperCase();
|
newCustomer.endercom = customer.address.toUpperCase();
|
||||||
newCustomer.numerocom = customer.addressNumber.toUpperCase();
|
newCustomer.numerocom = customer.addressNumber.toUpperCase();
|
||||||
if ( customer.complement !== null && customer.complement.length > 80 ) {
|
if (customer.complement !== null && customer.complement.length > 80) {
|
||||||
newCustomer.complementocom = customer.complement.substring(0, 80 ).toUpperCase();
|
newCustomer.complementocom = customer.complement.substring(0, 80).toUpperCase();
|
||||||
} else {
|
} else {
|
||||||
if ( customer.complement != null ) {
|
if (customer.complement != null) {
|
||||||
newCustomer.complementocom = customer.complement.toUpperCase();
|
newCustomer.complementocom = customer.complement.toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -300,10 +300,10 @@ export class CustomerService {
|
|||||||
newCustomer.cepcob = customer.zipCode;
|
newCustomer.cepcob = customer.zipCode;
|
||||||
newCustomer.endercob = customer.address.toUpperCase();
|
newCustomer.endercob = customer.address.toUpperCase();
|
||||||
newCustomer.numerocob = customer.addressNumber;
|
newCustomer.numerocob = customer.addressNumber;
|
||||||
if ( customer.complement !== null && customer.complement.length > 80 ) {
|
if (customer.complement !== null && customer.complement.length > 80) {
|
||||||
newCustomer.complementocob = customer.complement.substring(0, 80 ).toUpperCase();
|
newCustomer.complementocob = customer.complement.substring(0, 80).toUpperCase();
|
||||||
} else {
|
} else {
|
||||||
if ( customer.complement ) {
|
if (customer.complement) {
|
||||||
newCustomer.complementocob = customer.complement.toUpperCase();
|
newCustomer.complementocob = customer.complement.toUpperCase();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,7 +317,7 @@ export class CustomerService {
|
|||||||
newCustomer.codmunicipio = Number.parseInt(customer.ibgeCode);
|
newCustomer.codmunicipio = Number.parseInt(customer.ibgeCode);
|
||||||
newCustomer.codcidadecom = newCustomer.codcidade;
|
newCustomer.codcidadecom = newCustomer.codcidade;
|
||||||
newCustomer.dtnasc = customer.birthdate;
|
newCustomer.dtnasc = customer.birthdate;
|
||||||
newCustomer.meiocomunicacao = customer.communicate;
|
// newCustomer.meiocomunicacao = customer.communicate;
|
||||||
newCustomer.codfunccad = customer.idUser;
|
newCustomer.codfunccad = customer.idUser;
|
||||||
newCustomer.codfunccadastro = customer.idUser;
|
newCustomer.codfunccadastro = customer.idUser;
|
||||||
newCustomer.codfuncultalter = customer.idUser;
|
newCustomer.codfuncultalter = customer.idUser;
|
||||||
@@ -341,7 +341,7 @@ export class CustomerService {
|
|||||||
city: customer.city, state: customer.state,
|
city: customer.city, state: customer.state,
|
||||||
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
||||||
category: customer.category, subCategory: customer.subCategory,
|
category: customer.category, subCategory: customer.subCategory,
|
||||||
place: customer.place, ramo: customer.ramo, meiocomunicacao: customer.communicate,
|
place: customer.place, ramo: customer.ramo, /*meiocomunicacao: customer.communicate,*/
|
||||||
latitude: customer.latitude, longitude: customer.longitude, ibgeCode: customer.ibgeCode,
|
latitude: customer.latitude, longitude: customer.longitude, ibgeCode: customer.ibgeCode,
|
||||||
addressType: customer.addressType,
|
addressType: customer.addressType,
|
||||||
};
|
};
|
||||||
@@ -361,7 +361,7 @@ export class CustomerService {
|
|||||||
city: customer.city, state: customer.state,
|
city: customer.city, state: customer.state,
|
||||||
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
||||||
category: customer.category, subCategory: customer.subCategory,
|
category: customer.category, subCategory: customer.subCategory,
|
||||||
place: customer.place, meiocomunicacao: customer.communicate,
|
place: customer.place, /*meiocomunicacao: customer.communicate,*/
|
||||||
ramo: customer.ramo, latitude: customer.latitude, longitude: customer.longitude,
|
ramo: customer.ramo, latitude: customer.latitude, longitude: customer.longitude,
|
||||||
ibgeCode: customer.ibgeCode, addressType: customer.addressType,
|
ibgeCode: customer.ibgeCode, addressType: customer.addressType,
|
||||||
};
|
};
|
||||||
@@ -378,7 +378,7 @@ export class CustomerService {
|
|||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
try {
|
try {
|
||||||
console.log("MEIO DE COMUNICACAO: " + client.meiocomunicacao);
|
//console.log("MEIO DE COMUNICACAO: " + client.meiocomunicacao);
|
||||||
await queryRunner.manager
|
await queryRunner.manager
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.update(Pcclient)
|
.update(Pcclient)
|
||||||
@@ -419,7 +419,7 @@ export class CustomerService {
|
|||||||
codcidadecom: client.codcidade,
|
codcidadecom: client.codcidade,
|
||||||
dtnasc: client.dtnasc,
|
dtnasc: client.dtnasc,
|
||||||
codatv1: client.codatv1,
|
codatv1: client.codatv1,
|
||||||
meiocomunicacao: client.meiocomunicacao,
|
// meiocomunicacao: client.meiocomunicacao,
|
||||||
codfuncultalter: client.codfuncultalter,
|
codfuncultalter: client.codfuncultalter,
|
||||||
dtultalter: client.dtultalter,
|
dtultalter: client.dtultalter,
|
||||||
latitude: client.latitude,
|
latitude: client.latitude,
|
||||||
@@ -434,7 +434,7 @@ export class CustomerService {
|
|||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
throw err;
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
if ( queryRunner.isTransactionActive) {
|
if (queryRunner.isTransactionActive) {
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
}
|
}
|
||||||
await queryRunner.release();
|
await queryRunner.release();
|
||||||
@@ -533,12 +533,12 @@ export class CustomerService {
|
|||||||
const queryRunner = connection.createQueryRunner();
|
const queryRunner = connection.createQueryRunner();
|
||||||
try {
|
try {
|
||||||
|
|
||||||
await connection.connect();
|
await connection.connect();
|
||||||
|
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
|
|
||||||
// lets now open a new transaction:
|
// lets now open a new transaction:
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
|
|
||||||
|
|
||||||
let sql = `SELECT PROXNUMCLI as "proxnumcli" FROM PCCONSUM WHERE 1 = 1 FOR UPDATE`;
|
let sql = `SELECT PROXNUMCLI as "proxnumcli" FROM PCCONSUM WHERE 1 = 1 FOR UPDATE`;
|
||||||
@@ -566,14 +566,14 @@ export class CustomerService {
|
|||||||
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// since we have errors let's rollback changes we made
|
// since we have errors let's rollback changes we made
|
||||||
if ( queryRunner.isTransactionActive) {
|
if (queryRunner.isTransactionActive) {
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
}
|
}
|
||||||
console.log(err);
|
console.log(err);
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
if ( queryRunner.isTransactionActive) {
|
if (queryRunner.isTransactionActive) {
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
}
|
}
|
||||||
// you need to release query runner which is manually created:
|
// you need to release query runner which is manually created:
|
||||||
@@ -603,7 +603,7 @@ export class CustomerService {
|
|||||||
console.log(err);
|
console.log(err);
|
||||||
throw err;
|
throw err;
|
||||||
} finally {
|
} finally {
|
||||||
if ( queryRunner.isTransactionActive) {
|
if (queryRunner.isTransactionActive) {
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
}
|
}
|
||||||
await queryRunner.release();
|
await queryRunner.release();
|
||||||
|
|||||||
@@ -176,6 +176,20 @@ export class SalesController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Get('product/simil/:id')
|
||||||
|
@ApiOperation({ summary: 'Get products similar' })
|
||||||
|
@ApiParam({ name: 'id', description: 'Product ID' })
|
||||||
|
async getProductSimil(@Headers() headers, @Param('id') id: number) {
|
||||||
|
try {
|
||||||
|
const { store } = this.extractPaginationParams(headers);
|
||||||
|
return await this.salesService.GetProductsSimil(store, id);
|
||||||
|
} catch (e) {
|
||||||
|
throw new HttpException(e.message, HttpStatus.BAD_REQUEST);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Get('stock/:storeid/:id')
|
@Get('stock/:storeid/:id')
|
||||||
@ApiOperation({ summary: 'Get product stock information' })
|
@ApiOperation({ summary: 'Get product stock information' })
|
||||||
@ApiParam({ name: 'storeid', description: 'Store ID' })
|
@ApiParam({ name: 'storeid', description: 'Store ID' })
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import Redis = require('ioredis');
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class SalesService {
|
export class SalesService {
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@Inject('REDIS_CLIENT') private readonly redisClient: Redis.Redis,
|
@Inject('REDIS_CLIENT') private readonly redisClient: Redis.Redis,
|
||||||
private readonly customerService: CustomerService
|
private readonly customerService: CustomerService
|
||||||
) {}
|
) { }
|
||||||
|
|
||||||
|
|
||||||
async GetProducts2(store: string, pageSize: number, pageNumber: number, filter: FilterProduct = null,) {
|
async GetProducts2(store: string, pageSize: number, pageNumber: number, filter: FilterProduct = null,) {
|
||||||
@@ -77,9 +77,11 @@ export class SalesService {
|
|||||||
esvlistaprodutos.LETRABASETINTOMETRICO as "letter",
|
esvlistaprodutos.LETRABASETINTOMETRICO as "letter",
|
||||||
esvlistaprodutos.LINHATINTOMETRICO as "line",
|
esvlistaprodutos.LINHATINTOMETRICO as "line",
|
||||||
esvlistaprodutos.LITRAGEM as "can",
|
esvlistaprodutos.LITRAGEM as "can",
|
||||||
esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL as "full_stock"
|
esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL as "full_stock",
|
||||||
|
esvlistaprodutos.TEM_PRODUTO_SIMILAR as "similar",
|
||||||
|
NVL(esvlistaprodutos.TIPO, 'SEM') as "type_campaing"
|
||||||
FROM ESVLISTAPRODUTOS
|
FROM ESVLISTAPRODUTOS
|
||||||
WHERE 1 = 1`;
|
WHERE 1 = 1 `;
|
||||||
|
|
||||||
if (filter && filter.text.length > 0) {
|
if (filter && filter.text.length > 0) {
|
||||||
const description = filter.text.toUpperCase();
|
const description = filter.text.toUpperCase();
|
||||||
@@ -127,6 +129,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
||||||
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("UPPER(\"esvlistaprodutos\".CODFAB) LIKE '%'||REPLACE(:description, '@', '%')||'%'", { description })
|
.where("UPPER(\"esvlistaprodutos\".CODFAB) LIKE '%'||REPLACE(:description, '@', '%')||'%'", { description })
|
||||||
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
||||||
.andWhere("(\"esvlistaprodutos\".produto_com_reducao_preco = :produtoComReducaoPreco OR :produtoComReducaoPreco = 'N')",
|
.andWhere("(\"esvlistaprodutos\".produto_com_reducao_preco = :produtoComReducaoPreco OR :produtoComReducaoPreco = 'N')",
|
||||||
@@ -184,6 +188,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
||||||
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("UPPER(\"esvlistaprodutos\".descricao) LIKE '%'||REPLACE(:description, '@', '%')||'%'", { description })
|
.where("UPPER(\"esvlistaprodutos\".descricao) LIKE '%'||REPLACE(:description, '@', '%')||'%'", { description })
|
||||||
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
||||||
.andWhere("(\"esvlistaprodutos\".produto_com_reducao_preco = :produtoComReducaoPreco OR :produtoComReducaoPreco = 'N')",
|
.andWhere("(\"esvlistaprodutos\".produto_com_reducao_preco = :produtoComReducaoPreco OR :produtoComReducaoPreco = 'N')",
|
||||||
@@ -260,6 +266,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
||||||
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("esvlistaprodutos.brand in (" + xbrands + ")")
|
.where("esvlistaprodutos.brand in (" + xbrands + ")")
|
||||||
.andWhere("\"esvlistaprodutos\".URLCATEGORIA LIKE :urlCategoria||'%'", { urlCategoria: filter.urlCategory })
|
.andWhere("\"esvlistaprodutos\".URLCATEGORIA LIKE :urlCategoria||'%'", { urlCategoria: filter.urlCategory })
|
||||||
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
||||||
@@ -324,6 +332,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
.addSelect("\"esvlistaprodutos\".LINHATINTOMETRICO", "line")
|
||||||
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
.addSelect("\"esvlistaprodutos\".LITRAGEM", "can")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
.where("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
||||||
.andWhere("(\"esvlistaprodutos\".produto_com_reducao_preco = :produtoComReducaoPreco OR :produtoComReducaoPreco = 'N')",
|
.andWhere("(\"esvlistaprodutos\".produto_com_reducao_preco = :produtoComReducaoPreco OR :produtoComReducaoPreco = 'N')",
|
||||||
{ produtoComReducaoPreco: (filter.markdown.toString() == 'true') ? 'S' : 'N' })
|
{ produtoComReducaoPreco: (filter.markdown.toString() == 'true') ? 'S' : 'N' })
|
||||||
@@ -357,88 +367,88 @@ export class SalesService {
|
|||||||
pageSize: number,
|
pageSize: number,
|
||||||
pageNumber: number,
|
pageNumber: number,
|
||||||
urlDepartment: string
|
urlDepartment: string
|
||||||
): Promise<any> {
|
): Promise<any> {
|
||||||
const cacheKey =
|
const cacheKey =
|
||||||
'searchByDepartment:' +
|
'searchByDepartment:' +
|
||||||
store +
|
store +
|
||||||
'_' +
|
'_' +
|
||||||
pageSize +
|
pageSize +
|
||||||
'_' +
|
'_' +
|
||||||
pageNumber +
|
pageNumber +
|
||||||
'_' +
|
'_' +
|
||||||
urlDepartment;
|
urlDepartment;
|
||||||
const lockKey = 'lock:' + cacheKey;
|
const lockKey = 'lock:' + cacheKey;
|
||||||
const lockTimeout = 30; // lock expira em 30 segundos
|
const lockTimeout = 30; // lock expira em 30 segundos
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const cachedResult = await this.redisClient.get(cacheKey);
|
const cachedResult = await this.redisClient.get(cacheKey);
|
||||||
if (cachedResult) {
|
if (cachedResult) {
|
||||||
console.log('Retornando resultado do cache (searchByDepartment)');
|
console.log('Retornando resultado do cache (searchByDepartment)');
|
||||||
return JSON.parse(cachedResult);
|
return JSON.parse(cachedResult);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Erro ao acessar o Redis no searchByDepartment:', err?.message || err);
|
console.error('Erro ao acessar o Redis no searchByDepartment:', err?.message || err);
|
||||||
}
|
}
|
||||||
|
|
||||||
const lockValue = Date.now() + lockTimeout * 1000 + 1;
|
const lockValue = Date.now() + lockTimeout * 1000 + 1;
|
||||||
let acquiredLock: string | null = null;
|
let acquiredLock: string | null = null;
|
||||||
try {
|
try {
|
||||||
acquiredLock = await this.redisClient.set(lockKey, lockValue, 'NX', 'EX', lockTimeout);
|
acquiredLock = await this.redisClient.set(lockKey, lockValue, 'NX', 'EX', lockTimeout);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Erro ao adquirir lock no Redis (searchByDepartment):', err?.message || err);
|
console.error('Erro ao adquirir lock no Redis (searchByDepartment):', err?.message || err);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (acquiredLock === 'OK') {
|
if (acquiredLock === 'OK') {
|
||||||
const connectionDb = new Connection(connectionOptions);
|
const connectionDb = new Connection(connectionOptions);
|
||||||
await connectionDb.connect();
|
await connectionDb.connect();
|
||||||
const queryRunner = connectionDb.createQueryRunner();
|
const queryRunner = connectionDb.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
try {
|
|
||||||
if (pageSize === 0) pageSize = 50;
|
|
||||||
if (pageNumber === 0) pageNumber = 1;
|
|
||||||
const offSet = (pageNumber - 1) * pageSize;
|
|
||||||
|
|
||||||
let products = await queryRunner.manager
|
|
||||||
.getRepository(SalesProduct)
|
|
||||||
.createQueryBuilder('esvlistaprodutos')
|
|
||||||
.where('"esvlistaprodutos".urldepartamento = :urlDepartment', { urlDepartment })
|
|
||||||
.andWhere('("esvlistaprodutos".codfilial = :codfilial OR :codfilial = \'99\')', { codfilial: store })
|
|
||||||
.limit(pageSize)
|
|
||||||
.offset(offSet)
|
|
||||||
.orderBy('"esvlistaprodutos".DESCRICAO', 'ASC')
|
|
||||||
.getMany();
|
|
||||||
|
|
||||||
products = this.createListImages(products);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.redisClient.set(cacheKey, JSON.stringify(products), 'EX', 3600);
|
if (pageSize === 0) pageSize = 50;
|
||||||
} catch (cacheErr) {
|
if (pageNumber === 0) pageNumber = 1;
|
||||||
console.error('Erro ao salvar o resultado no cache (searchByDepartment):', cacheErr?.message || cacheErr);
|
const offSet = (pageNumber - 1) * pageSize;
|
||||||
}
|
|
||||||
|
|
||||||
return products;
|
let products = await queryRunner.manager
|
||||||
} catch (error) {
|
.getRepository(SalesProduct)
|
||||||
console.error('Erro ao executar a query no searchByDepartment:', error?.message || error);
|
.createQueryBuilder('esvlistaprodutos')
|
||||||
throw error;
|
.where('"esvlistaprodutos".urldepartamento = :urlDepartment', { urlDepartment })
|
||||||
} finally {
|
.andWhere('("esvlistaprodutos".codfilial = :codfilial OR :codfilial = \'99\')', { codfilial: store })
|
||||||
await queryRunner.release();
|
.limit(pageSize)
|
||||||
await connectionDb.close();
|
.offset(offSet)
|
||||||
|
.orderBy('"esvlistaprodutos".DESCRICAO', 'ASC')
|
||||||
|
.getMany();
|
||||||
|
|
||||||
try {
|
products = this.createListImages(products);
|
||||||
const currentLockValue = await this.redisClient.get(lockKey);
|
|
||||||
if (currentLockValue === lockValue.toString()) {
|
try {
|
||||||
await this.redisClient.del(lockKey);
|
await this.redisClient.set(cacheKey, JSON.stringify(products), 'EX', 3600);
|
||||||
}
|
} catch (cacheErr) {
|
||||||
} catch (lockErr) {
|
console.error('Erro ao salvar o resultado no cache (searchByDepartment):', cacheErr?.message || cacheErr);
|
||||||
console.error('Erro ao liberar o lock do Redis (searchByDepartment):', lockErr?.message || lockErr);
|
}
|
||||||
|
|
||||||
|
return products;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Erro ao executar a query no searchByDepartment:', error?.message || error);
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
await queryRunner.release();
|
||||||
|
await connectionDb.close();
|
||||||
|
|
||||||
|
try {
|
||||||
|
const currentLockValue = await this.redisClient.get(lockKey);
|
||||||
|
if (currentLockValue === lockValue.toString()) {
|
||||||
|
await this.redisClient.del(lockKey);
|
||||||
|
}
|
||||||
|
} catch (lockErr) {
|
||||||
|
console.error('Erro ao liberar o lock do Redis (searchByDepartment):', lockErr?.message || lockErr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
console.log('Lock não adquirido (searchByDepartment), aguardando e tentando novamente...');
|
console.log('Lock não adquirido (searchByDepartment), aguardando e tentando novamente...');
|
||||||
await this.sleep(1000);
|
await this.sleep(1000);
|
||||||
return this.searchByDepartment(store, pageSize, pageNumber, urlDepartment);
|
return this.searchByDepartment(store, pageSize, pageNumber, urlDepartment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -562,6 +572,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
||||||
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("esvlistaprodutos.idProduct = :id", { id: numbers })
|
.where("esvlistaprodutos.idProduct = :id", { id: numbers })
|
||||||
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99'", { codfilial: store })
|
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99'", { codfilial: store })
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
@@ -609,6 +621,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
||||||
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("esvlistaprodutos.CODAUXILIAR = :id", { id: numbers })
|
.where("esvlistaprodutos.CODAUXILIAR = :id", { id: numbers })
|
||||||
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
.andWhere("(\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99')", { codfilial: store })
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
@@ -658,6 +672,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
||||||
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("UPPER(esvlistaprodutos.CODFAB) like REPLACE(:description, '@', '%')", { description })
|
.where("UPPER(esvlistaprodutos.CODFAB) like REPLACE(:description, '@', '%')", { description })
|
||||||
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99'", { codfilial: store })
|
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99'", { codfilial: store })
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
@@ -704,6 +720,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
||||||
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("UPPER(esvlistaprodutos.DESCRICAO) like REPLACE(:description, '@', '%')", { description })
|
.where("UPPER(esvlistaprodutos.DESCRICAO) like REPLACE(:description, '@', '%')", { description })
|
||||||
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99'", { codfilial: store })
|
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial OR :codfilial = '99'", { codfilial: store })
|
||||||
.limit(pageSize)
|
.limit(pageSize)
|
||||||
@@ -773,6 +791,8 @@ export class SalesService {
|
|||||||
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
.addSelect("\"esvlistaprodutos\".PRODUTO_EM_CAMPANHA", "compaing")
|
||||||
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
.addSelect("\"esvlistaprodutos\".BASETINTOMETRICO", "base")
|
||||||
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
.addSelect("\"esvlistaprodutos\".QUANTIDADE_ESTOQUE_GERAL", "full_stock")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TEM_PRODUTO_SIMILAR", "similar")
|
||||||
|
.addSelect("\"esvlistaprodutos\".TIPO_CAMPANHA", "type_campaing")
|
||||||
.where("esvlistaprodutos.idProduct = :id", { id: id })
|
.where("esvlistaprodutos.idProduct = :id", { id: id })
|
||||||
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial", { codfilial: store })
|
.andWhere("\"esvlistaprodutos\".codfilial = :codfilial", { codfilial: store })
|
||||||
.orderBy("REPLACE(\"esvlistaprodutos\".DESCRICAO,'#', '')", "ASC")
|
.orderBy("REPLACE(\"esvlistaprodutos\".DESCRICAO,'#', '')", "ASC")
|
||||||
@@ -834,6 +854,8 @@ export class SalesService {
|
|||||||
,esvlistaprodutos.PRODUTO_EM_CAMPANHA as "compaing"
|
,esvlistaprodutos.PRODUTO_EM_CAMPANHA as "compaing"
|
||||||
,esvlistaprodutos.BASETINTOMETRICO as "base"
|
,esvlistaprodutos.BASETINTOMETRICO as "base"
|
||||||
,esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL as "full_stock"
|
,esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL as "full_stock"
|
||||||
|
,esvlistaprodutos.TEM_PRODUTO_SIMILAR as "similar"
|
||||||
|
,esvlistaprodutos.TIPO_CAMPANHA as "type_campaing"
|
||||||
FROM ESVLISTAPRODUTOS, ESTCOMPREJUNTO
|
FROM ESVLISTAPRODUTOS, ESTCOMPREJUNTO
|
||||||
WHERE ESVLISTAPRODUTOS.CODPROD = ESTCOMPREJUNTO.CODPROD
|
WHERE ESVLISTAPRODUTOS.CODPROD = ESTCOMPREJUNTO.CODPROD
|
||||||
AND ESTCOMPREJUNTO.CODPRODVENDA = ${id}
|
AND ESTCOMPREJUNTO.CODPRODVENDA = ${id}
|
||||||
@@ -851,6 +873,68 @@ export class SalesService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async GetProductsSimil(store: string, id: number) {
|
||||||
|
const connectionDb = new Connection(connectionOptions);
|
||||||
|
await connectionDb.connect();
|
||||||
|
const queryRunner = connectionDb.createQueryRunner();
|
||||||
|
await queryRunner.connect();
|
||||||
|
try {
|
||||||
|
const sql = `SELECT esvlistaprodutos.CODPROD as "idProduct"
|
||||||
|
,esvlistaprodutos.SEQ as "seq"
|
||||||
|
,esvlistaprodutos.DESCRICAO as "smallDescription"
|
||||||
|
,esvlistaprodutos.NOMEECOMMERCE as "title"
|
||||||
|
,esvlistaprodutos.CODFAB as "idProvider"
|
||||||
|
,esvlistaprodutos.CODAUXILIAR as "ean"
|
||||||
|
,esvlistaprodutos.TIPOPRODUTO as "productType"
|
||||||
|
,esvlistaprodutos.DADOSTECNICOS as "technicalData"
|
||||||
|
,esvlistaprodutos.INFORMACOESTECNICAS as "description"
|
||||||
|
,esvlistaprodutos.URLIMAGEM as "urlImage"
|
||||||
|
,esvlistaprodutos.NOMEMARCA as "brand"
|
||||||
|
,esvlistaprodutos.NOMEDEPARTAMENTO as "department"
|
||||||
|
,esvlistaprodutos.NOMESECAO as "section"
|
||||||
|
,esvlistaprodutos.NOMECATEGORIA as "category"
|
||||||
|
,esvlistaprodutos.NOMEFORNECEDOR as "supplier"
|
||||||
|
,esvlistaprodutos.CODIGOFILIAL as "store"
|
||||||
|
,esvlistaprodutos.CLASSEVENDA as "saleAbc"
|
||||||
|
,esvlistaprodutos.CLASSEESTOQUE as "stockAbc"
|
||||||
|
,esvlistaprodutos.FORALINHA as "outLine"
|
||||||
|
,esvlistaprodutos.PRECOVENDA as "listPrice"
|
||||||
|
,esvlistaprodutos.PRECOPROMOCIONAL as "salePrice"
|
||||||
|
,esvlistaprodutos.PRECOPROMOCIONAL as "salePromotion"
|
||||||
|
,esvlistaprodutos.PERCENTUALDESCONTO as"offPercent"
|
||||||
|
,esvlistaprodutos.QTESTOQUE_DISPONIVEL as "stock"
|
||||||
|
,esvlistaprodutos.QTCAIXAS as "boxStock"
|
||||||
|
,esvlistaprodutos.ESTOQUE_DISP_LOJA as "store_stock"
|
||||||
|
,esvlistaprodutos.ESTOQUE_DISP_CAIXA_LOJA as "store_boxStock"
|
||||||
|
,esvlistaprodutos.ESTOQUE_DISP_LOJA as "store_stock"
|
||||||
|
,esvlistaprodutos.ESTOQUE_DISP_CAIXA_LOJA as "store_boxStock"
|
||||||
|
,esvlistaprodutos.MULTIPLO as "mutiple"
|
||||||
|
,esvlistaprodutos.UNIDADE as "unity"
|
||||||
|
,esvlistaprodutos.URLDEPARTAMENTO as "urlDepartment"
|
||||||
|
,esvlistaprodutos.URLSECAO as "urlSection"
|
||||||
|
,esvlistaprodutos.PRODUTO_COM_REDUCAO_PRECO as "downPrice"
|
||||||
|
,esvlistaprodutos.PRODUTO_EM_CAMPANHA as "compaing"
|
||||||
|
,esvlistaprodutos.BASETINTOMETRICO as "base"
|
||||||
|
,esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL as "full_stock"
|
||||||
|
,esvlistaprodutos.TEM_PRODUTO_SIMILAR as "similar"
|
||||||
|
,esvlistaprodutos.TIPO_CAMPANHA as "type_campaing"
|
||||||
|
FROM ESVLISTAPRODUTOS, PCPRODSIMIL
|
||||||
|
WHERE ESVLISTAPRODUTOS.CODPROD = PCPRODSIMIL.CODSIMIL
|
||||||
|
AND PCPRODSIMIL.CODPROD = ${id}
|
||||||
|
AND ESVLISTAPRODUTOS.CODFILIAL = '${store}'
|
||||||
|
ORDER BY REPLACE(esvlistaprodutos.DESCRICAO,'#', '')`;
|
||||||
|
let products: SalesProduct[] = await queryRunner.query(sql);
|
||||||
|
|
||||||
|
products = this.createListImages(products);
|
||||||
|
return products;
|
||||||
|
} catch (error) {
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
await queryRunner.release();
|
||||||
|
await connectionDb.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async GetStocks(storeId: string, id: number) {
|
async GetStocks(storeId: string, id: number) {
|
||||||
const connectionDb = new Connection(connectionOptions);
|
const connectionDb = new Connection(connectionOptions);
|
||||||
await connectionDb.connect();
|
await connectionDb.connect();
|
||||||
@@ -1127,67 +1211,67 @@ export class SalesService {
|
|||||||
const lockKey = 'departments_lock';
|
const lockKey = 'departments_lock';
|
||||||
const lockTimeout = 30;
|
const lockTimeout = 30;
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
const cachedDepartments = await this.redisClient.get(cacheKey);
|
// const cachedDepartments = await this.redisClient.get(cacheKey);
|
||||||
if (cachedDepartments) {
|
// if (cachedDepartments) {
|
||||||
console.log('Buscando departamentos no Redis');
|
// console.log('Buscando departamentos no Redis');
|
||||||
return JSON.parse(cachedDepartments);
|
// return JSON.parse(cachedDepartments);
|
||||||
}
|
// }
|
||||||
} catch (err) {
|
// } catch (err) {
|
||||||
console.error('Erro ao acessar o Redis (cache):', err);
|
// console.error('Erro ao acessar o Redis (cache):', err);
|
||||||
}
|
// }
|
||||||
const lockValue = Date.now() + lockTimeout * 1000 + 1;
|
const lockValue = Date.now() + lockTimeout * 1000 + 1;
|
||||||
const acquiredLock = await this.redisClient.set(lockKey, lockValue, 'NX', 'EX', lockTimeout);
|
const acquiredLock = await this.redisClient.set(lockKey, lockValue, 'NX', 'EX', lockTimeout);
|
||||||
|
|
||||||
if (acquiredLock === 'OK') {
|
if (acquiredLock === 'OK') {
|
||||||
const connectionDb = new Connection(connectionOptions);
|
const connectionDb = new Connection(connectionOptions);
|
||||||
await connectionDb.connect();
|
await connectionDb.connect();
|
||||||
const queryRunner = connectionDb.createQueryRunner();
|
const queryRunner = connectionDb.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
|
|
||||||
try {
|
|
||||||
const departments = await queryRunner.manager
|
|
||||||
.getRepository(Esvdepartamento)
|
|
||||||
.createQueryBuilder('Esvdepartamento')
|
|
||||||
.innerJoinAndSelect('Esvdepartamento.secoes', 'secoes')
|
|
||||||
.innerJoinAndSelect('secoes.categorias', 'categorias')
|
|
||||||
.where('"Esvdepartamento".tituloecommerce is not null')
|
|
||||||
.orderBy('"Esvdepartamento".tituloecommerce, "secoes".tituloecommerce, "categorias".tituloecommerce')
|
|
||||||
.getMany();
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.redisClient.set(cacheKey, JSON.stringify(departments), 'EX', 3600);
|
const departments = await queryRunner.manager
|
||||||
} catch (cacheErr) {
|
.getRepository(Esvdepartamento)
|
||||||
console.error('Erro ao armazenar dados no Redis:', cacheErr);
|
.createQueryBuilder('Esvdepartamento')
|
||||||
}
|
.innerJoinAndSelect('Esvdepartamento.secoes', 'secoes')
|
||||||
|
.leftJoinAndSelect('secoes.categorias', 'categorias')
|
||||||
|
.where('"Esvdepartamento".tituloecommerce is not null')
|
||||||
|
.orderBy('"Esvdepartamento".tituloecommerce, "secoes".tituloecommerce, "categorias".tituloecommerce')
|
||||||
|
.getMany();
|
||||||
|
|
||||||
return departments;
|
try {
|
||||||
} catch (dbErr) {
|
await this.redisClient.set(cacheKey, JSON.stringify(departments), 'EX', 3600);
|
||||||
console.error('Erro na consulta ao banco de dados:', dbErr);
|
} catch (cacheErr) {
|
||||||
throw dbErr;
|
console.error('Erro ao armazenar dados no Redis:', cacheErr);
|
||||||
} finally {
|
}
|
||||||
await queryRunner.release();
|
|
||||||
await connectionDb.close();
|
|
||||||
|
|
||||||
// Libera o lock somente se ainda for o proprietário
|
return departments;
|
||||||
try {
|
} catch (dbErr) {
|
||||||
const currentLockValue = await this.redisClient.get(lockKey);
|
console.error('Erro na consulta ao banco de dados:', dbErr);
|
||||||
if (currentLockValue === lockValue.toString()) {
|
throw dbErr;
|
||||||
await this.redisClient.del(lockKey);
|
} finally {
|
||||||
}
|
await queryRunner.release();
|
||||||
} catch (lockErr) {
|
await connectionDb.close();
|
||||||
console.error('Erro ao liberar o lock do Redis:', lockErr);
|
|
||||||
|
// Libera o lock somente se ainda for o proprietário
|
||||||
|
try {
|
||||||
|
const currentLockValue = await this.redisClient.get(lockKey);
|
||||||
|
if (currentLockValue === lockValue.toString()) {
|
||||||
|
await this.redisClient.del(lockKey);
|
||||||
|
}
|
||||||
|
} catch (lockErr) {
|
||||||
|
console.error('Erro ao liberar o lock do Redis:', lockErr);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
console.log('Lock não adquirido, aguardando a liberação...');
|
console.log('Lock não adquirido, aguardando a liberação...');
|
||||||
await this.sleep(1000); // aguarda 1 segundo
|
await this.sleep(1000); // aguarda 1 segundo
|
||||||
return this.getDepartments();
|
return this.getDepartments();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private sleep(ms: number): Promise<void> {
|
private sleep(ms: number): Promise<void> {
|
||||||
return new Promise(resolve => setTimeout(resolve, ms));
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1265,8 +1349,10 @@ export class SalesService {
|
|||||||
' ,esvlistaprodutos.LINHATINTOMETRICO "line" ' +
|
' ,esvlistaprodutos.LINHATINTOMETRICO "line" ' +
|
||||||
' ,esvlistaprodutos.LITRAGEM "can" ' +
|
' ,esvlistaprodutos.LITRAGEM "can" ' +
|
||||||
' ,esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL "full_stock" ' +
|
' ,esvlistaprodutos.QUANTIDADE_ESTOQUE_GERAL "full_stock" ' +
|
||||||
|
' ,esvlistaprodutos.TEM_PRODUTO_SIMILAR "similar" ' +
|
||||||
|
' ,esvlistaprodutos.TIPO_CAMPANHA "type_campaing" ' +
|
||||||
' FROM esvlistaprodutos ' +
|
' FROM esvlistaprodutos ' +
|
||||||
' WHERE 1 = 1';
|
' WHERE 1 = 1 ';
|
||||||
|
|
||||||
let where = "";
|
let where = "";
|
||||||
if (filter.text != null) {
|
if (filter.text != null) {
|
||||||
@@ -1362,7 +1448,7 @@ export class SalesService {
|
|||||||
const queryRunner = connectionDb.createQueryRunner();
|
const queryRunner = connectionDb.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
try {
|
try {
|
||||||
const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
/*const sql = 'SELECT ESVCALCULOFRETE.CODTABELAFRETE as "id" ' +
|
||||||
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
|
' ,ESVCALCULOFRETE.CODFILIAL as "store" ' +
|
||||||
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
||||||
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
||||||
@@ -1376,7 +1462,22 @@ export class SalesService {
|
|||||||
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
||||||
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
||||||
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
' 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
|
const deliveryTaxTable = await queryRunner.manager
|
||||||
.query(sql, [cityId, cartId]);
|
.query(sql, [cityId, cartId]);
|
||||||
@@ -1402,7 +1503,7 @@ export class SalesService {
|
|||||||
WHERE ID = '${cartId}'`;
|
WHERE ID = '${cartId}'`;
|
||||||
|
|
||||||
await queryRunner.manager
|
await queryRunner.manager
|
||||||
.query(sql);
|
.query(sql);
|
||||||
await queryRunner.commitTransaction();
|
await queryRunner.commitTransaction();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
await queryRunner.rollbackTransaction();
|
await queryRunner.rollbackTransaction();
|
||||||
@@ -1428,7 +1529,22 @@ export class SalesService {
|
|||||||
const queryRunner = connectionDb.createQueryRunner();
|
const queryRunner = connectionDb.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
try {
|
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.CODFILIAL as "store" ' +
|
||||||
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
' ,ESVCALCULOFRETE.CODCIDADE as "cityId" ' +
|
||||||
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
' ,PCCIDADE.NOMECIDADE as "cityName" ' +
|
||||||
@@ -1442,7 +1558,7 @@ export class SalesService {
|
|||||||
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
' AND ESVCALCULOFRETE.CODCIDADE = PCCIDADE.CODCIDADE ' +
|
||||||
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
' AND ESVCALCULOFRETE.CODCIDADE = :1 ' +
|
||||||
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
' AND ESVCALCULOFRETE.IDCART = :2 ' +
|
||||||
' ORDER BY VLFRETE';
|
' ORDER BY VLFRETE';*/
|
||||||
|
|
||||||
let deliveryTaxTable = await queryRunner.manager
|
let deliveryTaxTable = await queryRunner.manager
|
||||||
.query(sql, [dataDeliveryTax.cityId, dataDeliveryTax.cartId]);
|
.query(sql, [dataDeliveryTax.cityId, dataDeliveryTax.cartId]);
|
||||||
@@ -1494,7 +1610,7 @@ export class SalesService {
|
|||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
try {
|
try {
|
||||||
const sql = `SELECT ESF_CALCULAR_PRAZO_ENTREGA_PROGRAMADA(TO_DATE('${saleDate}', 'DD-MM-YYYY'), ${invoiceStoreId}, ${placeId}, '${cartId}') AS "days" FROM DUAL`;
|
const sql = `SELECT ESF_CALCULAR_PRAZO_ENTREGA_PROGRAMADA(TO_DATE('${saleDate}', 'DD-MM-YYYY'), ${invoiceStoreId}, ${placeId}, '${cartId}') AS "days" FROM DUAL`;
|
||||||
// const sql = `SELECT ESF_CALCULAR_PRAZO_ENTREGA(TO_DATE('${saleDate}', 'DD-MM-YYYY')) AS "days" FROM DUAL`;
|
// const sql = `SELECT ESF_CALCULAR_PRAZO_ENTREGA(TO_DATE('${saleDate}', 'DD-MM-YYYY')) AS "days" FROM DUAL`;
|
||||||
const timeDays = await queryRunner.query(sql);
|
const timeDays = await queryRunner.query(sql);
|
||||||
|
|
||||||
const sqlRetiraPosterior = `SELECT ( PROXIMO_DIA_UTIL(TO_DATE('${saleDate}', 'DD-MM-YYYY'), '4') - TRUNC(SYSDATE) ) AS "days" FROM DUAL`;
|
const sqlRetiraPosterior = `SELECT ( PROXIMO_DIA_UTIL(TO_DATE('${saleDate}', 'DD-MM-YYYY'), '4') - TRUNC(SYSDATE) ) AS "days" FROM DUAL`;
|
||||||
|
|||||||
Reference in New Issue
Block a user