feat: Add new sales and shopping cart management module.
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m45s
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 1m45s
This commit is contained in:
@@ -1613,7 +1613,7 @@ export class SalesService {
|
||||
// const sql = `SELECT ESF_CALCULAR_PRAZO_ENTREGA(TO_DATE('${saleDate}', 'DD-MM-YYYY')) AS "days" FROM DUAL`;
|
||||
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'), '1') - TRUNC(SYSDATE) ) AS "days" FROM DUAL`;
|
||||
const timeDaysRetiraPosterior = await queryRunner.query(sqlRetiraPosterior);
|
||||
|
||||
return { deliveryDays: timeDays[0].days, retiraPosteriorDays: timeDaysRetiraPosterior[0].days };
|
||||
|
||||
@@ -6,6 +6,7 @@ import { OrderDiscount } from 'src/domain/models/order-discount.model';
|
||||
import { OrderTaxDelivery } from 'src/domain/models/order-taxdelivery.model';
|
||||
import { LogOrder } from 'src/domain/models/log-order.model';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Cart } from 'src/domain/models/cart.model';
|
||||
|
||||
@ApiTags('Shopping')
|
||||
@Controller('api/v1/shopping')
|
||||
@@ -39,6 +40,15 @@ export class ShoppingController {
|
||||
}
|
||||
}
|
||||
|
||||
@Put('cart')
|
||||
async updateCart(@Body() cart: Cart) {
|
||||
try {
|
||||
return await this.shoppingService.updateShopping(cart);
|
||||
} catch (error) {
|
||||
throw new HttpException(error.message, HttpStatus.BAD_REQUEST);
|
||||
}
|
||||
}
|
||||
|
||||
@Get('cart/:idcart/item/:idProduct/tipoentrega/:deliveryType')
|
||||
async getItemCart(@Req() request, @Param('idCart') idCart: string,
|
||||
@Param('idProduct') idProduct: string, @Param('deliveryType') deliveryType: string) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Shopping } from 'src/domain/entity/tables/estprevendac.entity';
|
||||
import { OrderTaxDelivery } from 'src/domain/models/order-taxdelivery.model';
|
||||
import { connectionOptions } from 'src/configs/typeorm.config';
|
||||
import { LogOrder } from 'src/domain/models/log-order.model';
|
||||
import { Cart } from 'src/domain/models/cart.model';
|
||||
|
||||
@Injectable()
|
||||
export class ShoppingService {
|
||||
@@ -605,6 +606,39 @@ export class ShoppingService {
|
||||
}
|
||||
}
|
||||
|
||||
async updateShopping(shopping: any) {
|
||||
const connection = new Connection(connectionOptions);
|
||||
await connection.connect();
|
||||
const queryRunner = connection.createQueryRunner();
|
||||
await queryRunner.connect();
|
||||
try {
|
||||
console.log(JSON.stringify(shopping));
|
||||
const sql = `UPDATE ESTPREVENDAC
|
||||
SET ESTPREVENDAC.CODCLI = :codcli
|
||||
,ESTPREVENDAC.codendentcli = :codendentcli
|
||||
,ESTPREVENDAC.codplpag = :codplpag
|
||||
,ESTPREVENDAC.codcob = :codcob
|
||||
,ESTPREVENDAC.codfilial = :codfilial
|
||||
WHERE ID = :id `;
|
||||
|
||||
await queryRunner.query(sql, [
|
||||
shopping.codcli,
|
||||
shopping.codendentcli,
|
||||
shopping.codplpag,
|
||||
shopping.codcob,
|
||||
shopping.saleStore,
|
||||
shopping.id
|
||||
]);
|
||||
|
||||
return shopping;
|
||||
} catch (error) {
|
||||
throw error;
|
||||
} finally {
|
||||
await queryRunner.release();
|
||||
await connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
async updatePriceShopping(idCart: string, idPaymentPlan: number) {
|
||||
const connection = new Connection(connectionOptions);
|
||||
await connection.connect();
|
||||
|
||||
Reference in New Issue
Block a user