homolog #1
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)))'
|
||||||
27
.gitea/workflows/deploy-api.yaml
Normal file
27
.gitea/workflows/deploy-api.yaml
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
name: Deploy NestJS API
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push-deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Login no Harbor
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.HARBOR_PASSWORD }}" | docker login 172.35.0.216 -u ${{ secrets.HARBOR_USERNAME }} --password-stdin
|
||||||
|
|
||||||
|
- name: Build e Push
|
||||||
|
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
|
||||||
|
|
||||||
|
docker push 172.35.0.216/library/vendaweb-api:$TAG
|
||||||
|
docker push 172.35.0.216/library/vendaweb-api:latest
|
||||||
|
|
||||||
|
- name: Notificar Portainer via Webhook
|
||||||
|
run: |
|
||||||
|
# O Webhook avisa o Portainer para puxar a nova imagem imediatamente
|
||||||
|
curl -X POST "${{ secrets.PORTAINER_WEBHOOK_VENDAWEBAPI }}"
|
||||||
7
.gitea/workflows/rollback.md
Normal file
7
.gitea/workflows/rollback.md
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
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.
|
||||||
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
|
||||||
|
|
||||||
|
|||||||
45
Dockerfile
45
Dockerfile
@@ -1,32 +1,39 @@
|
|||||||
FROM node:16
|
# Estágio 1: Build
|
||||||
|
FROM node:16-bullseye-slim AS builder
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
COPY package*.json ./
|
||||||
|
RUN npm install --legacy-peer-deps
|
||||||
|
COPY . .
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
FROM node:16-bullseye-slim
|
||||||
|
# Instalar dependências do Oracle
|
||||||
RUN apt-get update && apt-get install -y \
|
RUN apt-get update && apt-get install -y \
|
||||||
apt-transport-https \
|
|
||||||
ca-certificates \
|
|
||||||
libaio1 \
|
libaio1 \
|
||||||
unzip \
|
unzip \
|
||||||
wget \
|
wget \
|
||||||
libc6 \
|
&& mkdir -p /opt/oracle
|
||||||
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
|
|
||||||
|
|
||||||
|
# Instalar Oracle Instant Client
|
||||||
|
RUN wget https://download.oracle.com/otn_software/linux/instantclient/instantclient-basic-linuxx64.zip -O /opt/oracle/client.zip && \
|
||||||
|
unzip /opt/oracle/client.zip -d /opt/oracle && \
|
||||||
|
rm /opt/oracle/client.zip && \
|
||||||
|
ln -s /opt/oracle/instantclient_* /opt/oracle/instantclient
|
||||||
|
|
||||||
|
# Configurar o sistema para encontrar as bibliotecas do Oracle
|
||||||
|
ENV LD_LIBRARY_PATH=/opt/oracle/instantclient
|
||||||
|
RUN echo "/opt/oracle/instantclient" > /etc/ld.so.conf.d/oracle-instantclient.conf && ldconfig
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
# Copiar apenas o necessário do estágio anterior
|
||||||
|
COPY --from=builder /app/dist ./dist
|
||||||
|
COPY --from=builder /app/package*.json ./
|
||||||
|
COPY --from=builder /app/node_modules ./node_modules
|
||||||
|
|
||||||
COPY package*.json ./
|
# Variáveis de ambiente padrão para o driver oracledb
|
||||||
|
ENV OCI_LIB_DIR=/opt/oracle/instantclient
|
||||||
|
ENV OCI_INC_DIR=/opt/oracle/instantclient/sdk/include
|
||||||
RUN npm install --legacy-peer-deps
|
|
||||||
|
|
||||||
COPY . .
|
|
||||||
|
|
||||||
|
|
||||||
CMD ["npm", "run", "start:prod"]
|
CMD ["npm", "run", "start:prod"]
|
||||||
@@ -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
|
||||||
@@ -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 2026' };
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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}'],
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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,15 +267,15 @@ 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();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -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();
|
||||||
@@ -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' })
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ 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' })
|
||||||
@@ -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,15 +1211,15 @@ 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);
|
||||||
|
|
||||||
@@ -1150,7 +1234,7 @@ export class SalesService {
|
|||||||
.getRepository(Esvdepartamento)
|
.getRepository(Esvdepartamento)
|
||||||
.createQueryBuilder('Esvdepartamento')
|
.createQueryBuilder('Esvdepartamento')
|
||||||
.innerJoinAndSelect('Esvdepartamento.secoes', 'secoes')
|
.innerJoinAndSelect('Esvdepartamento.secoes', 'secoes')
|
||||||
.innerJoinAndSelect('secoes.categorias', 'categorias')
|
.leftJoinAndSelect('secoes.categorias', 'categorias')
|
||||||
.where('"Esvdepartamento".tituloecommerce is not null')
|
.where('"Esvdepartamento".tituloecommerce is not null')
|
||||||
.orderBy('"Esvdepartamento".tituloecommerce, "secoes".tituloecommerce, "categorias".tituloecommerce')
|
.orderBy('"Esvdepartamento".tituloecommerce, "secoes".tituloecommerce, "categorias".tituloecommerce')
|
||||||
.getMany();
|
.getMany();
|
||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user