mirror of
https://git.imnavajas.es/jjimenez/erp-imprimelibros.git
synced 2026-02-11 05:19:14 +00:00
sistema de pedidos pendientes de pago hechos
This commit is contained in:
@ -231,20 +231,9 @@ public class PaymentController {
|
||||
})
|
||||
.add("transfer_id", pago -> {
|
||||
if (pago.getPayment() != null) {
|
||||
String responsePayload = pago.getResponsePayload();
|
||||
Long cartId = null;
|
||||
if (responsePayload != null && !responsePayload.isBlank()) {
|
||||
try {
|
||||
JsonNode node = new ObjectMapper().readTree(responsePayload);
|
||||
if (node.has("cartId")) {
|
||||
cartId = node.get("cartId").asLong();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
cartId = null;
|
||||
}
|
||||
}
|
||||
if (cartId != null) {
|
||||
return "TRANSF-" + cartId;
|
||||
Long pedido = pago.getPayment().getOrderId();
|
||||
if (pedido != null) {
|
||||
return "TRANSF-" + pedido;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
|
||||
@ -51,7 +51,7 @@ public class PaymentService {
|
||||
}
|
||||
|
||||
public Payment findFailedPaymentByOrderId(Long orderId) {
|
||||
return payRepo.findByOrderIdAndStatus(orderId, PaymentStatus.failed)
|
||||
return payRepo.findFirstByOrderIdAndStatusOrderByIdDesc(orderId, PaymentStatus.failed)
|
||||
.orElse(null);
|
||||
}
|
||||
|
||||
@ -69,11 +69,17 @@ public class PaymentService {
|
||||
var node = om.readTree(resp_payload);
|
||||
Long cartId = null;
|
||||
Long dirFactId = null;
|
||||
if (node.has("cartId")) {
|
||||
cartId = node.get("cartId").asLong();
|
||||
}
|
||||
if (node.has("dirFactId")) {
|
||||
dirFactId = node.get("dirFactId").asLong();
|
||||
if (node.has("Ds_MerchantData")) {
|
||||
// format: "Ds_MerchantData": "{"dirFactId":3,"cartId":90}"
|
||||
String merchantData = node.get("Ds_MerchantData").asText();
|
||||
merchantData = merchantData.replace(""", "\"");
|
||||
var mdNode = om.readTree(merchantData);
|
||||
if (mdNode.has("cartId")) {
|
||||
cartId = mdNode.get("cartId").asLong();
|
||||
}
|
||||
if (mdNode.has("dirFactId")) {
|
||||
dirFactId = mdNode.get("dirFactId").asLong();
|
||||
}
|
||||
}
|
||||
return Map.of(
|
||||
"cartId", cartId,
|
||||
|
||||
@ -10,5 +10,5 @@ import java.util.Optional;
|
||||
|
||||
public interface PaymentRepository extends JpaRepository<Payment, Long> {
|
||||
Optional<Payment> findByGatewayAndGatewayOrderId(String gateway, String gatewayOrderId);
|
||||
Optional<Payment> findByOrderIdAndStatus(Long orderId, PaymentStatus status);
|
||||
Optional<Payment> findFirstByOrderIdAndStatusOrderByIdDesc(Long orderId, PaymentStatus status);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user