mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-11 05:19:14 +00:00
arreglados varios temas además del DL (redsys, etc)
This commit is contained in:
@ -32,7 +32,6 @@ import com.imprimelibros.erp.users.UserDao;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/pagos")
|
||||
|
||||
@ -273,6 +273,14 @@ public class PaymentService {
|
||||
throw new IllegalStateException("Error al solicitar la devolución a Redsys", e);
|
||||
}
|
||||
|
||||
// 🔧 NORMALIZAR ANTES DE GUARDAR
|
||||
if (gatewayRefundId != null) {
|
||||
gatewayRefundId = gatewayRefundId.trim();
|
||||
if (gatewayRefundId.isEmpty() || "000000".equals(gatewayRefundId)) {
|
||||
gatewayRefundId = null; // → múltiples NULL NO rompen el UNIQUE
|
||||
}
|
||||
}
|
||||
|
||||
PaymentTransaction tx = new PaymentTransaction();
|
||||
tx.setPayment(p);
|
||||
tx.setType(PaymentTransactionType.REFUND);
|
||||
|
||||
@ -6,9 +6,6 @@ import java.time.LocalDateTime;
|
||||
@Entity
|
||||
@Table(
|
||||
name = "payment_transactions",
|
||||
uniqueConstraints = {
|
||||
@UniqueConstraint(name = "uq_tx_gateway_txid", columnNames = {"gateway_transaction_id"})
|
||||
},
|
||||
indexes = {
|
||||
@Index(name = "idx_tx_pay", columnList = "payment_id"),
|
||||
@Index(name = "idx_tx_type_status", columnList = "type,status"),
|
||||
|
||||
@ -8,10 +8,11 @@ import com.imprimelibros.erp.payments.model.PaymentTransactionType;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface PaymentTransactionRepository extends JpaRepository<PaymentTransaction, Long>, JpaSpecificationExecutor<PaymentTransaction> {
|
||||
Optional<PaymentTransaction> findByGatewayTransactionId(String gatewayTransactionId);
|
||||
List<PaymentTransaction> findByGatewayTransactionId(String gatewayTransactionId);
|
||||
Optional<PaymentTransaction> findByIdempotencyKey(String idempotencyKey);
|
||||
Optional<PaymentTransaction> findFirstByPaymentIdAndTypeAndStatusOrderByIdDesc(
|
||||
Long paymentId,
|
||||
|
||||
Reference in New Issue
Block a user