From 5d3c9a46a3cde34eae35d7cf95ce2b8e0960b517 Mon Sep 17 00:00:00 2001 From: Prince Date: Fri, 12 Jun 2026 23:48:47 +0200 Subject: [PATCH] improved polling logi --- .../tm/domain/services/ProviderService.java | 10 +- .../HotRechargeIntegrationProcessor.java | 6 +- .../resources/liquibase-diff-changeLog.xml | 92 ++++++++----------- 3 files changed, 49 insertions(+), 59 deletions(-) diff --git a/src/main/java/zw/qantra/tm/domain/services/ProviderService.java b/src/main/java/zw/qantra/tm/domain/services/ProviderService.java index c94195a..203ad7d 100644 --- a/src/main/java/zw/qantra/tm/domain/services/ProviderService.java +++ b/src/main/java/zw/qantra/tm/domain/services/ProviderService.java @@ -144,19 +144,17 @@ public class ProviderService { return meta.get("hotProductId"); } - public String getExternalId(String providerId, String productUuid) { + public String getExternalId(String providerId, String productName) { try { - UUID productUid = UUID.fromString(productUuid); - List products = getProviderProducts(providerId); return products.stream() - .filter(product -> product.getUid().equals(productUid)) + .filter(product -> product.getName().equals(productName)) .map(SBZProductDto::getExternalId) .findFirst() .orElse(null); - } catch (IllegalArgumentException e) { - log.error("Invalid UUID format: " + productUuid, e); + } catch (Exception e) { + log.error("Failed to fetch external Id: " + productName, e); return null; } } diff --git a/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java b/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java index 605c8ac..70c0e5b 100644 --- a/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java +++ b/src/main/java/zw/qantra/tm/domain/services/processors/integrations/HotRechargeIntegrationProcessor.java @@ -14,6 +14,7 @@ import zw.qantra.tm.domain.enums.CurrencyType; import zw.qantra.tm.domain.enums.RequestType; import zw.qantra.tm.domain.enums.Status; import zw.qantra.tm.domain.models.AdditionalData; +import zw.qantra.tm.domain.models.Provider; import zw.qantra.tm.domain.models.Transaction; import zw.qantra.tm.domain.services.*; import zw.qantra.tm.domain.services.processors.TransactionProcessorInterface; @@ -170,13 +171,16 @@ public class HotRechargeIntegrationProcessor implements TransactionProcessorInte // do this for Econet bundles if(providerId.equals("111")) { - String productCode = providerService.getExternalId(providerId, transaction.getProductUid()); + Provider provider = providerService.getProviderRepository() + .findByClientId(transaction.getBillClientId()); + String productCode = providerService.getExternalId(provider.getId().toString(), transaction.getBillProductName()); List> rechargeOptions = new ArrayList<>(); Map option = new LinkedHashMap<>(); option.put("Name", "ProductCode"); option.put("ParameterType", "String"); option.put("Value", productCode); rechargeOptions.add(option); + request.put("RechargeOptions", rechargeOptions); } logger.info("Sending recharge request: {}", request); diff --git a/src/main/resources/liquibase-diff-changeLog.xml b/src/main/resources/liquibase-diff-changeLog.xml index 00baab4..f3308c9 100644 --- a/src/main/resources/liquibase-diff-changeLog.xml +++ b/src/main/resources/liquibase-diff-changeLog.xml @@ -1,224 +1,212 @@ - - - - - - - - - - - - - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - + - +