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

View File

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

View File

@@ -11,8 +11,8 @@ export const environment = {
// url: 'http://10.1.1.210:8065/api/v1/', // url: 'http://10.1.1.210:8065/api/v1/',
// url: 'http://172.35.0.216:8065/api/v1/', // url: 'http://172.35.0.216:8065/api/v1/',
//url: 'http://10.1.1.23:8065/api/v1/', //url: 'http://10.1.1.23:8065/api/v1/',
url: 'https://api.vendaweb.simplifiquehc.com.br/api/v1/', //url: 'https://api.vendaweb.simplifiquehc.com.br/api/v1/',
// url: 'http://10.1.1.124:8065/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/',
URL_PIX: 'http://10.1.1.205:8078/api/v1/', URL_PIX: 'http://10.1.1.205:8078/api/v1/',