This commit is contained in:
Mohd-Arham
2025-11-24 09:56:31 +05:30
parent bb38775e5b
commit 3a7a278774
10 changed files with 168 additions and 23 deletions
@@ -1,7 +1,6 @@
// java
package com.billpaymentservice.bbps.serviceImpl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -13,6 +12,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.billpaymentservice.bbps.dto.ContactMaster;
import com.billpaymentservice.bbps.dto.CustomParamDTO;
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
@@ -29,6 +29,7 @@ import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
import com.billpaymentservice.bbps.dto.response.BillerResponse;
import com.billpaymentservice.bbps.dto.response.ChannelsListResponse;
import com.billpaymentservice.bbps.dto.response.ContactMasterResponse;
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
import com.billpaymentservice.bbps.dto.response.CustomerParamGroupsResponse;
import com.billpaymentservice.bbps.dto.response.DispositionResponse;
@@ -42,7 +43,6 @@ import com.billpaymentservice.bbps.entites.CustomParam;
import com.billpaymentservice.bbps.entites.DispositionDetails;
import com.billpaymentservice.bbps.entites.InboundTraceLog;
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
import com.billpaymentservice.bbps.entites.TicketDispositionDetails;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
import com.billpaymentservice.bbps.repository.BillerDataRepository;
@@ -51,7 +51,6 @@ import com.billpaymentservice.bbps.repository.DispositionRepository;
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.MerchantRepository;
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.TicketDispositionRepository;
import com.billpaymentservice.bbps.service.MasterDataService;
import com.billpaymentservice.bbps.util.BBPSConstant;
import com.billpaymentservice.bbps.util.BillerMapperHelper;
@@ -73,7 +72,7 @@ public class MasterDataServiceImpl implements MasterDataService {
private MerchantRepository merchantRegisterRepo;
private HttpClientApi httpClientApi;
private final DispositionRepository dispositionRepository;
private final Helper helper;
private final BillerDataRepository billerDataRespository;
private final HttpService httpService;
@@ -98,7 +97,6 @@ public class MasterDataServiceImpl implements MasterDataService {
this.outboundTraceLogRepository = outboundTraceLogRepository;
this.mapperHelper = mapperHelper;
this.customParamReposiotory = customParamReposiotory;
}
@@ -173,8 +171,8 @@ public class MasterDataServiceImpl implements MasterDataService {
String requestJson = helper.convertObjectToJson(billerDetailRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
"POST", requestJson);
System.out.println( billerDataRespository.findByBillerId(billerId));
System.out.println(billerDataRespository.findByBillerId(billerId));
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
@@ -274,8 +272,60 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
LOGGER.info("Fetching Contact Master Request Data " + contactMasterRequest);
return new ResponseModel(); // things not comming from api
String txnID = helper.generateTxnId(15);
String apiName = "FetchMasterDataCategoryWise";
String requestId = contactMasterRequest.getReqId();
String requestJson = helper.convertObjectToJson(contactMasterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
"POST", requestJson);
try {
helper.validateMerchant(contactMasterRequest.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL,
headersData.getTenantId(), contactMasterRequest.getCategory());
LOGGER.info("Contact Master Full URL-:" + fullUrl);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
LOGGER.info("Response Data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
throw new CustomException(String.valueOf(dataMap.get("message")), // message
String.valueOf(dataMap.get("status")), // status
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
String.valueOf(dataMap.get("remarks")) // remarks
);
}
ContactMasterResponse responseWrapper = objectMapper.convertValue(dataMap, ContactMasterResponse.class);
String result = mapperHelper.saveContactMasterData(responseWrapper.getContactMasterList(), requestId,
txnID);
LOGGER.info("Result Master Contact Data -:" + result);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
@Override