Compare commits

..

2 Commits

Author SHA1 Message Date
Luis Eduardo Estevao
32d4a3f2b9 Merge branch 'main' of https://git.simplifiquehc.com.br/simplifique/Vendaweb-portal
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 6m21s
2026-02-11 11:05:31 -03:00
Luis Eduardo Estevao
c58290621a feat: implement shopping cart and sales functionality with new component, service, and environment configuration. 2026-02-11 11:05:23 -03:00
3 changed files with 46 additions and 28 deletions

View File

@@ -604,6 +604,8 @@ export class CartSalesComponent
this.stores.find((s) => s.id === this.authService.getStore())
);
localStorage.setItem('invoiceStore', saveStoreInvoice);
this.updateCart(this.shoppingService.getCart());
}
this.formPayment.patchValue({
invoiceStore: JSON.parse(saveStoreInvoice),
@@ -750,6 +752,7 @@ export class CartSalesComponent
if (localStorage.getItem('paymentPlan') === 'undefined') {
localStorage.setItem('paymentPlan', JSON.stringify(paymentPlan));
this.selectPaymentPlan = paymentPlan;
this.updateCart(this.shoppingService.getCart());
this.confirmChangePaymentPlan(true);
} else {
this.selectPaymentPlan = paymentPlan;
@@ -767,6 +770,7 @@ export class CartSalesComponent
'paymentPlan',
JSON.stringify(this.selectPaymentPlan)
);
this.updateCart(this.shoppingService.getCart());
const billing = JSON.parse(localStorage.getItem('billing')) as Billing;
this.idPaymentPlan = this.selectPaymentPlan.codplpag;
this.subscriptionUpdatePayment = this.shoppingService
@@ -807,6 +811,7 @@ export class CartSalesComponent
tap((planos) => console.log(planos))
)
.subscribe();
this.updateCart(this.shoppingService.getCart());
}
setPartner(partner: any) {
@@ -815,6 +820,7 @@ export class CartSalesComponent
setInvoiceStore(invoiceStore: any) {
localStorage.setItem('invoiceStore', JSON.stringify(invoiceStore));
this.updateCart(this.shoppingService.getCart());
}
isInvoiceStore9Or10() {
@@ -930,14 +936,14 @@ export class CartSalesComponent
const customer = JSON.parse(localStorage.getItem('customer')) as Customer;
if (localStorage.getItem('customer') != undefined) {
if (customer.place.id == 19) {
this.titleInformation = 'Pedido de venda';
this.messageInformation = 'ATENÇÃO! Cliente com praça do E-COMMERCE!';
this.informationDescription =
'Altere a praça do cliente pela opção NOVO CLIENTE para continuar.';
this.showInformation = true;
return;
}
// if (customer.place.id == 19) {
// this.titleInformation = 'Pedido de venda';
// this.messageInformation = 'ATENÇÃO! Cliente com praça do E-COMMERCE!';
// this.informationDescription =
// 'Altere a praça do cliente pela opção NOVO CLIENTE para continuar.';
// this.showInformation = true;
// return;
// }
if (
customer.place.name == 'INATIVO' ||
customer.place.name == 'INATIVA'
@@ -1000,6 +1006,7 @@ export class CartSalesComponent
}
this.updateFormCustomer(result);
localStorage.setItem('customer', JSON.stringify(result));
this.updateCart(this.shoppingService.getCart());
this.updateTaxDelivery();
}
}
@@ -1579,20 +1586,29 @@ export class CartSalesComponent
}
public updateCart(
cartId: string,
customerId: number,
addressId: number,
saleStoreId: string,
paymentPlanId: number,
billingId: string
cartId: string
) {
console.log('Atualizando carrinho: ' + cartId);
this.shoppingService.getShopping(cartId).subscribe((shopping) => {
if (shopping) {
shopping.codcli = customerId;
shopping.codendentcli = addressId;
shopping.saleStore = saleStoreId;
shopping.codplpag = paymentPlanId;
shopping.codcob = billingId;
console.log('Carrinho encontrado: ' + JSON.stringify(shopping));
const invoiceStore = JSON.parse(
localStorage.getItem('invoiceStore')
) as StoreERP;
const customer = JSON.parse(localStorage.getItem('customer')) as Customer;
const address = JSON.parse(
localStorage.getItem('address')
) as CustomerAddress;
const paymentPlan = JSON.parse(
localStorage.getItem('paymentPlan')
) as PaymentPlan;
const billing = JSON.parse(localStorage.getItem('billing')) as Billing;
shopping.codcli = customer ? customer.customerId : 0;
shopping.codendentcli = address ? address.idAddress : 0;
shopping.saleStore = invoiceStore ? invoiceStore.id : this.authService.getStore();
shopping.codplpag = paymentPlan ? paymentPlan.codplpag : 0;
shopping.codcob = billing ? billing.codcob : '';
this.shoppingService.updateShopping(shopping).subscribe(
(response) => {
@@ -1630,6 +1646,7 @@ export class CartSalesComponent
this.showSelectAddress = false;
if (result != null) {
localStorage.setItem('address', JSON.stringify(result));
this.updateCart(this.shoppingService.getCart());
this.updateFormAddress(result);
this.updateTaxDelivery();
}
@@ -2331,6 +2348,7 @@ export class CartSalesComponent
if (action === 'Sim') {
if (this.customer !== undefined && this.customer.customerId !== 1) {
localStorage.setItem('customer', JSON.stringify(this.customer));
this.updateCart(this.shoppingService.getCart());
this.updateFormCustomer(this.customer);
} else {
localStorage.setItem(

View File

@@ -28,7 +28,7 @@ export class ShoppingService {
constructor(
private httpClient: HttpClient,
private messageService: MessageService
) {}
) { }
getShoppingItems(idCart: string): Observable<ShoppingItem[]> {
if (idCart == null || idCart === '') {
@@ -72,7 +72,7 @@ export class ShoppingService {
updateShopping(shopping: Shopping) {
const resp = this.httpClient
.put<Shopping>(`${environment.url}shopping/${shopping.id}`, shopping)
.put<Shopping>(`${environment.url}shopping/cart`, shopping)
.pipe(
map((response) => {
console.log('Retorno atualização item: ' + response);
@@ -115,11 +115,11 @@ export class ShoppingService {
const url = `${environment.url}shopping/update/payment/${idCart}`;
console.log(
'Url: ' +
url +
' - cart: ' +
idCart +
' - payment: ' +
JSON.stringify(payment)
url +
' - cart: ' +
idCart +
' - payment: ' +
JSON.stringify(payment)
);
const resp = this.httpClient.put<ResultApi>(url, payment).pipe(
map((response) => {

View File

@@ -11,8 +11,8 @@ export const environment = {
// url: 'http://10.1.1.210:8065/api/v1/',
// url: 'http://172.35.0.216:8065/api/v1/',
//url: 'http://10.1.1.23:8065/api/v1/',
url: 'https://api.vendaweb.simplifiquehc.com.br/api/v1/',
// url: 'http://10.1.1.124:8065/api/v1/',
//url: 'https://api.vendaweb.simplifiquehc.com.br/api/v1/',
url: 'http://localhost:8067/api/v1/',
// URL_PIX: 'http://10.1.1.205:8078/api/v1/',
URL_PIX: 'http://10.1.1.205:8078/api/v1/',