minor fixes on confirmations
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
package zw.qantra.tm.config;
|
package zw.qantra.tm.configs;
|
||||||
|
|
||||||
import com.github.benmanes.caffeine.cache.Caffeine;
|
import com.github.benmanes.caffeine.cache.Caffeine;
|
||||||
import org.springframework.cache.CacheManager;
|
import org.springframework.cache.CacheManager;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package zw.qantra.tm.domain.controllers;
|
package zw.qantra.tm.domain.controllers;
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.cache.CacheManager;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
@@ -36,6 +37,13 @@ public class ConfigController {
|
|||||||
private final ProviderService providerService;
|
private final ProviderService providerService;
|
||||||
private final CategoryService categoryService;
|
private final CategoryService categoryService;
|
||||||
private final IntegrationProcessorService integrationProcessorService;
|
private final IntegrationProcessorService integrationProcessorService;
|
||||||
|
private final CacheManager cacheManager;
|
||||||
|
|
||||||
|
@GetMapping("/cache/clear")
|
||||||
|
public ResponseEntity clearCache(){
|
||||||
|
cacheManager.getCacheNames().forEach(name -> cacheManager.getCache(name).clear());
|
||||||
|
return ResponseEntity.ok("Cache cleared");
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/seed/live")
|
@GetMapping("/seed/live")
|
||||||
public ResponseEntity seedLiveConfig(){
|
public ResponseEntity seedLiveConfig(){
|
||||||
|
|||||||
@@ -73,14 +73,17 @@ public class ProviderService {
|
|||||||
return products;
|
return products;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Cacheable(value = "providerProducts", key = "#providerId")
|
@Cacheable(value = "providerProducts", key = "#providerUid")
|
||||||
public List<SBZProductDto> getProviderProducts(String providerId) {
|
public List<SBZProductDto> getProviderProducts(String providerUid) {
|
||||||
try {
|
try {
|
||||||
Provider provider = providerRepository.findByClientId(providerId);
|
Provider provider = providerRepository.findById(UUID.fromString(providerUid)).orElse(null);
|
||||||
if (provider == null) {
|
if (provider == null) {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
String stockUrl = hotApiUrl + "/query/stock/" + 111;
|
Map<String, String> meta = Utils.fromJson(provider.getMeta(), Map.class);
|
||||||
|
String providerId = meta.get("hotProductId");
|
||||||
|
|
||||||
|
String stockUrl = hotApiUrl + "/query/stock/" + providerId;
|
||||||
HttpHeaders headers = new HttpHeaders();
|
HttpHeaders headers = new HttpHeaders();
|
||||||
String token = hotRechargeTokenService.getToken();
|
String token = hotRechargeTokenService.getToken();
|
||||||
headers.setBearerAuth(token);
|
headers.setBearerAuth(token);
|
||||||
@@ -91,8 +94,8 @@ public class ProviderService {
|
|||||||
List<SBZProductDto> products = new ArrayList<>();
|
List<SBZProductDto> products = new ArrayList<>();
|
||||||
for (Object item : stock) {
|
for (Object item : stock) {
|
||||||
LinkedHashMap<String, Object> stockItem = (LinkedHashMap<String, Object>) item;
|
LinkedHashMap<String, Object> stockItem = (LinkedHashMap<String, Object>) item;
|
||||||
String stockProviderId = (String) stockItem.get("providerId");
|
int stockProviderId = (int) stockItem.get("productId"); // providerId is referred to as productId in the stock response
|
||||||
if (stockProviderId.equals(providerId)) {
|
if (String.valueOf(stockProviderId).equals(providerId)) {
|
||||||
log.info("Found matching provider in stock: " + stockItem);
|
log.info("Found matching provider in stock: " + stockItem);
|
||||||
|
|
||||||
SBZProductDto sbzProductDto = new SBZProductDto();
|
SBZProductDto sbzProductDto = new SBZProductDto();
|
||||||
|
|||||||
@@ -54,6 +54,12 @@ public class NetoneConfirmationHotProcessor implements TransactionProcessorInter
|
|||||||
put("name", "Destination Phone Number");
|
put("name", "Destination Phone Number");
|
||||||
put("value", transaction.getCreditAccount());
|
put("value", transaction.getCreditAccount());
|
||||||
}});
|
}});
|
||||||
|
if(transaction.getBillProductName() != null && !transaction.getBillProductName().isEmpty()) {
|
||||||
|
additionalDataList.add(new HashMap() {{
|
||||||
|
put("name", "Product");
|
||||||
|
put("value", transaction.getBillProductName());
|
||||||
|
}});
|
||||||
|
}
|
||||||
transaction.setAdditionalData(additionalDataList);
|
transaction.setAdditionalData(additionalDataList);
|
||||||
|
|
||||||
AdditionalData additionalData = AdditionalData.builder()
|
AdditionalData additionalData = AdditionalData.builder()
|
||||||
|
|||||||
Reference in New Issue
Block a user