mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-01-13 00:48:49 +00:00
falta la vista de los presupuestos aceptados
This commit is contained in:
@ -15,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import com.imprimelibros.erp.payments.repo.WebhookEventRepository;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Locale;
|
||||
import java.util.Objects;
|
||||
|
||||
@Service
|
||||
@ -82,7 +83,7 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void handleRedsysNotification(String dsSignature, String dsMerchantParameters) throws Exception {
|
||||
public void handleRedsysNotification(String dsSignature, String dsMerchantParameters, Locale locale) throws Exception {
|
||||
|
||||
// 0) Intentamos parsear la notificación. Si falla, registramos el webhook crudo
|
||||
// y salimos.
|
||||
@ -197,7 +198,7 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
if (authorized) {
|
||||
processOrder(notif.cartId);
|
||||
processOrder(notif.cartId, locale);
|
||||
}
|
||||
|
||||
payRepo.save(p);
|
||||
@ -317,7 +318,7 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void markBankTransferAsCaptured(Long paymentId) {
|
||||
public void markBankTransferAsCaptured(Long paymentId, Locale locale) {
|
||||
Payment p = payRepo.findById(paymentId)
|
||||
.orElseThrow(() -> new IllegalArgumentException("Payment no encontrado: " + paymentId));
|
||||
|
||||
@ -354,7 +355,7 @@ public class PaymentService {
|
||||
|
||||
// 4) Procesar el pedido asociado al carrito (si existe)
|
||||
if (p.getOrderId() != null) {
|
||||
processOrder(p.getOrderId());
|
||||
processOrder(p.getOrderId(), locale);
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,19 +451,26 @@ public class PaymentService {
|
||||
return code >= 0 && code <= 99;
|
||||
}
|
||||
|
||||
private Boolean processOrder(Long cartId) {
|
||||
// GENERAR PEDIDO A PARTIR DEL CARRITO
|
||||
/**
|
||||
* Procesa el pedido asociado al carrito:
|
||||
* - bloquea el carrito
|
||||
* - crea el pedido a partir del carrito
|
||||
*
|
||||
*/
|
||||
private Boolean processOrder(Long cartId, Locale locale) {
|
||||
|
||||
Cart cart = this.cartService.findById(cartId);
|
||||
if (cart != null) {
|
||||
// Bloqueamos el carrito
|
||||
this.cartService.lockCartById(cart.getId());
|
||||
// Creamos el pedido
|
||||
this.cartService.crearPedido(cart.getId());
|
||||
// order ID es generado dentro de createOrderFromCart donde se marcan los
|
||||
// presupuestos como no editables
|
||||
// Long orderId =
|
||||
// this.cartService.pedidoService.createOrderFromCart(cart.getId(), p.getId());
|
||||
// p.setOrderId(orderId);
|
||||
Long orderId = this.cartService.crearPedido(cart.getId(), locale);
|
||||
if(orderId == null){
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
// envio de correo de confirmacion de pedido podria ir aqui
|
||||
}
|
||||
|
||||
}
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user