Incluida coluna tipo de endereço (NORMAL/PORTO/CONDOMINIO) no endereço do cliente
This commit is contained in:
@@ -49,6 +49,7 @@ export class CustomerService {
|
||||
' ,pcclient.longitude as "longitude" ' +
|
||||
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
||||
' ,pcclient.codcidade as "cityId" ' +
|
||||
' ,pcclient.tipoendereco as "addressType" ' +
|
||||
' FROM pcclient, pccidade ' +
|
||||
' WHERE pcclient.codcidade = pccidade.codcidade (+)';
|
||||
let where = ` AND ( pcclient.cliente like '%'||'${auxName.replace('@', '%')}'||'%' OR ` +
|
||||
@@ -59,7 +60,18 @@ export class CustomerService {
|
||||
const pagination = ` OFFSET 0 ROWS FETCH NEXT 100 ROWS ONLY`;
|
||||
const customers = await queryRunner.manager
|
||||
.query(sql + where + orderBy + pagination) as Customer[];
|
||||
return customers;
|
||||
let customerList: Customer[] = [];
|
||||
for (let i = 0; i < customers.length; i++) {
|
||||
let customer = customers[i];
|
||||
const place = await queryRunner.query(`SELECT PCPRACA.CODPRACA as "placeId"
|
||||
,PCPRACA.PRACA as "name"
|
||||
FROM PCPRACA
|
||||
WHERE PCPRACA.CODPRACA = ${customer.placeId}`);
|
||||
|
||||
customer.place = place[0];
|
||||
customerList.push(customer);
|
||||
}
|
||||
return customerList;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
@@ -102,6 +114,7 @@ export class CustomerService {
|
||||
' ,pcclient.longitude as "longitude" ' +
|
||||
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
||||
' ,pcclient.codcidade as "cityId" ' +
|
||||
' ,pcclient.tipoendereco as "addressType" ' +
|
||||
' FROM pcclient, pccidade ' +
|
||||
' WHERE pcclient.codcidade = pccidade.codcidade (+)';
|
||||
const where = ` AND REGEXP_REPLACE(pcclient.cgcent, '[^0-9]', '') =REGEXP_REPLACE('${cpf}', '[^0-9]', '')`;
|
||||
@@ -150,11 +163,17 @@ export class CustomerService {
|
||||
' ,pcclient.longitude as "longitude" ' +
|
||||
' ,pcclient.codmunicipio as "ibgeCode" ' +
|
||||
' ,pcclient.codcidade as "cityId" ' +
|
||||
' ,pcclient.tipoendereco as "addressType" ' +
|
||||
' FROM pcclient, pccidade ' +
|
||||
' WHERE pcclient.codcidade = pccidade.codcidade (+)';
|
||||
const where = ` AND pcclient.codcli = ${idCustomer}`;
|
||||
const customer = await queryRunner.query(sql + where);
|
||||
return customer[0];
|
||||
const place = await queryRunner.query(`SELECT PCPRACA.CODPRACA as "placeId"
|
||||
,PCPRACA.PRACA as "name"
|
||||
FROM PCPRACA
|
||||
WHERE PCPRACA.CODPRACA = ${customer[0].placeId}`);
|
||||
|
||||
return {...customer[0], place: place[0]};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
throw error;
|
||||
@@ -216,6 +235,7 @@ export class CustomerService {
|
||||
.addSelect("\"pcclient\".longitude as \"longitude\"")
|
||||
.addSelect("\"pcclient\".codmunicipio as \"ibgeCode\"")
|
||||
.addSelect("\"pcclient\".codcidade as \"cityId\"")
|
||||
.addSelect("\"pcclient\".esc_tipoeclieente as \"addressType\"")
|
||||
.where(where)
|
||||
.andWhere("\"pcclient\".CODCLI NOT IN (2) AND \"pcclient\".DTEXCLUSAO IS NULL")
|
||||
.getRawMany();
|
||||
@@ -304,6 +324,7 @@ export class CustomerService {
|
||||
newCustomer.dtultalter = new Date();
|
||||
newCustomer.latitude = customer.latitude;
|
||||
newCustomer.longitude = customer.longitude;
|
||||
newCustomer.tipoendereco = customer.addressType;
|
||||
|
||||
const oldCustomer = await this.findCustomerByCpf(newCustomer.cgcent);
|
||||
if (oldCustomer) {
|
||||
@@ -321,7 +342,8 @@ export class CustomerService {
|
||||
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
||||
category: customer.category, subCategory: customer.subCategory,
|
||||
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,
|
||||
};
|
||||
} else {
|
||||
const idCustomer = await this.generateIdCustomer();
|
||||
@@ -340,7 +362,8 @@ export class CustomerService {
|
||||
allowMessage: customer.allowMessage, cellPhone: customer.cellPhone,
|
||||
category: customer.category, subCategory: customer.subCategory,
|
||||
place: customer.place, meiocomunicacao: customer.communicate,
|
||||
ramo: customer.ramo, latitude: customer.latitude, longitude: customer.longitude, ibgeCode: customer.ibgeCode
|
||||
ramo: customer.ramo, latitude: customer.latitude, longitude: customer.longitude,
|
||||
ibgeCode: customer.ibgeCode, addressType: customer.addressType,
|
||||
};
|
||||
}
|
||||
} catch (error) {
|
||||
@@ -400,7 +423,8 @@ export class CustomerService {
|
||||
codfuncultalter: client.codfuncultalter,
|
||||
dtultalter: client.dtultalter,
|
||||
latitude: client.latitude,
|
||||
longitude: client.longitude,
|
||||
longitude: client.longitude,
|
||||
tipoendereco: client.tipoendereco
|
||||
})
|
||||
.where({ codcli: client.codcli })
|
||||
.execute();
|
||||
|
||||
Reference in New Issue
Block a user