solved conflicts

This commit is contained in:
Lincpay Tech
2025-11-11 11:03:30 +05:30
34 changed files with 1497 additions and 345 deletions
@@ -12,7 +12,10 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
import com.billpaymentservice.bbps.dto.CustomParamDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.MasterApiResponse;
import com.billpaymentservice.bbps.dto.ResponseModel;
@@ -33,6 +36,7 @@ import com.billpaymentservice.bbps.dto.response.DispositionResponse;
import com.billpaymentservice.bbps.dto.response.PlanResponse;
import com.billpaymentservice.bbps.dto.response.PlaneCategoriesResponse;
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
import com.billpaymentservice.bbps.entites.BillerDetails;
import com.billpaymentservice.bbps.entites.CustomParam;
import com.billpaymentservice.bbps.entites.DispositionDetails;
@@ -48,6 +52,7 @@ import com.billpaymentservice.bbps.repository.MerchantRepository;
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
import com.billpaymentservice.bbps.service.MasterDataService;
import com.billpaymentservice.bbps.util.BBPSConstant;
import com.billpaymentservice.bbps.util.BillerMapperHelper;
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
import com.billpaymentservice.bbps.util.Helper;
import com.fasterxml.jackson.core.JsonProcessingException;
@@ -62,7 +67,7 @@ public class MasterDataServiceImpl implements MasterDataService {
@Value("${master.data.url}")
private String masterRegisterUrl;
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
private final BillerMapperHelper mapperHelper;
private MerchantRepository merchantRegisterRepo;
private HttpClientApi httpClientApi;
private final DispositionRepository dispositionRepository;
@@ -77,9 +82,8 @@ public class MasterDataServiceImpl implements MasterDataService {
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
DispositionRepository dispositionRepository, BharatConnectMasterRepository beneficiaryDetailsRepository,
InboundTraceLogRepository inboundTraceLogRepository,
OutboundTraceLogRepository outboundTraceLogRepository,
CustomParamRepository customParamReposiotory) {
InboundTraceLogRepository inboundTraceLogRepository, OutboundTraceLogRepository outboundTraceLogRepository,
BillerMapperHelper mapperHelper, CustomParamRepository customParamReposiotory) {
this.merchantRegisterRepo = merchantRegisterRepo;
this.httpService = httpService;
this.httpClientApi = httpClientApi;
@@ -89,7 +93,8 @@ public class MasterDataServiceImpl implements MasterDataService {
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
this.inboundTraceLogRepository = inboundTraceLogRepository;
this.outboundTraceLogRepository = outboundTraceLogRepository;
this.customParamReposiotory=customParamReposiotory;
this.mapperHelper = mapperHelper;
this.customParamReposiotory = customParamReposiotory;
}
@@ -117,8 +122,9 @@ public class MasterDataServiceImpl implements MasterDataService {
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);
LOGGER.info("Response Data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
@@ -145,12 +151,14 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
@Override
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
LOGGER.info("Fetching Biller Detail By Biller Id for ReqId={} and MID={}", billerDetailRequest.getReqId(), billerDetailRequest.getMid());
LOGGER.info("Fetching Biller Detail By Biller Id for ReqId={} and MID={}", billerDetailRequest.getReqId(),
billerDetailRequest.getMid());
helper.validateMerchant(billerDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
@@ -159,8 +167,8 @@ public class MasterDataServiceImpl implements MasterDataService {
String billerId = billerDetailRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
String requestJson = helper.convertObjectToJson(billerDetailRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(), "POST",
requestJson);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
"POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
@@ -193,20 +201,21 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
@Override
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
LOGGER.info("Fetching Customer Param By Biller Id for ReqId={} and MID={}", customerParamRequest.getReqId(), customerParamRequest.getMid());
LOGGER.info("Fetching Customer Param By Biller Id for ReqId={} and MID={}", customerParamRequest.getReqId(),
customerParamRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetCustomerParamByBillerId";
String requestId = customerParamRequest.getReqId();
String requestJson = helper.convertObjectToJson(customerParamRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(), "POST",
requestJson);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
"POST", requestJson);
try {
helper.validateMerchant(customerParamRequest.getMid());
@@ -231,21 +240,20 @@ public class MasterDataServiceImpl implements MasterDataService {
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
String.valueOf(dataMap.get("remarks")));
}
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
List<CustomParamDTO> customParams = responseWrapper.getCustomParamResp();
GeneralResp generalResp = responseWrapper.getGeneralResp();
List<CustomParamDTO> customParam = responseWrapper.getCustomParamResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
GeneralResp generalResp = responseWrapper.getGeneralResp();
List<CustomParamDTO> customParam = responseWrapper.getCustomParamResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
// Map DTOs to entities
List<CustomParam> entities = customParams.stream().map(dto -> mapper.map(dto, CustomParam.class))
.collect(Collectors.toList());
// Save all to DB
customParamReposiotory.saveAll(entities);
// Map DTOs to entities
List<CustomParam> entities = customParams.stream()
.map(dto -> mapper.map(dto, CustomParam.class))
.collect(Collectors.toList());
// Save all to DB
customParamReposiotory.saveAll(entities);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
@@ -261,12 +269,13 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
return new ResponseModel(); //things not comming from api
return new ResponseModel(); // things not comming from api
}
@Override
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
LOGGER.info("Fetching Master Data Category-wise for ReqId={} and MID={}", masterRequest.getReqId(), masterRequest.getMid());
LOGGER.info("Fetching Master Data CategoryResponseList-wise " + masterRequest);
String txnID = helper.generateTxnId(15);
String apiName = "FetchMasterDataCategoryWise";
String requestId = masterRequest.getReqId();
@@ -301,6 +310,9 @@ public class MasterDataServiceImpl implements MasterDataService {
}
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.class);
List<BillerCategoryWise> savedEntities = mapperHelper.mapAndSaveAll(responseWrapper.getBillerResp(),
requestId, txnID);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -318,16 +330,15 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
LOGGER.info("Fetching Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(), dispositionDetailRequest.getMid());
LOGGER.info("Fetching Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetDispositionDetails";
String requestId = dispositionDetailRequest.getReqId();
helper.validateMerchant(dispositionDetailRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, dispositionDetailRequest.getMid(),
"GET", "N/A");
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
dispositionDetailRequest.getMid(), "GET", "N/A");
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
@@ -337,7 +348,7 @@ public class MasterDataServiceImpl implements MasterDataService {
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> dataMap = objectMapper.readValue(responseData,
@@ -377,12 +388,14 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
@Override
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchCustomerParamGroup";
String requestId = requestModel.getReqId();
@@ -415,6 +428,9 @@ public class MasterDataServiceImpl implements MasterDataService {
CustomerParamGroupsResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
CustomerParamGroupsDTO responseDTO = mapperHelper
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
@@ -426,14 +442,15 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
@Override
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchAllMasterAmountOption";
String requestId = requestModel.getReqId();
@@ -465,6 +482,10 @@ public class MasterDataServiceImpl implements MasterDataService {
}
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class);
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
txnID);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -484,7 +505,7 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanCategorie";
String requestId = requestModel.getReqId();
@@ -516,6 +537,8 @@ public class MasterDataServiceImpl implements MasterDataService {
}
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId, txnID);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -529,12 +552,14 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
@Override
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchInitiatingChannel";
String requestId = requestModel.getReqId();
@@ -546,7 +571,6 @@ public class MasterDataServiceImpl implements MasterDataService {
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling Master API: {}", fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
@@ -581,76 +605,70 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanByCategories";
String requestId = requestModel.getReqId();
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanByCategories";
String requestId = requestModel.getReqId();
helper.validateMerchant(requestModel.getMid());
helper.validateMerchant(requestModel.getMid());
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d",
masterRegisterUrl,
BBPSConstant.PLANS_URL,
requestModel.getBillerId(),
requestModel.getCategory() != null ? "&category=" + requestModel.getCategory() : "",
requestModel.getAmountInRupees() != null ? "&amountInRupees=" + requestModel.getAmountInRupees() : "",
requestModel.getCircle() != null ? "&circle=" + requestModel.getCircle() : "",
requestModel.getPage(),
requestModel.getPagesize()
);
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
requestModel.getCategory() != null ? "&category=" + requestModel.getCategory() : "",
requestModel.getAmountInRupees() != null ? "&amountInRupees=" + requestModel.getAmountInRupees() : "",
requestModel.getCircle() != null ? "&circle=" + requestModel.getCircle() : "", requestModel.getPage(),
requestModel.getPagesize());
LOGGER.info("Calling Master API: {}", url);
LOGGER.info("Calling Master API: {}", url);
// Convert request to JSON and create inbound & outbound logs
String requestJson = helper.convertObjectToJson(requestModel);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
// Convert request to JSON and create inbound & outbound logs
String requestJson = helper.convertObjectToJson(requestModel);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
try {
Map<String, String> apiResponse = httpService.getRequest(url);
String responseData = apiResponse.get("data");
LOGGER.info("Response Data: {}", responseData);
try {
Map<String, String> apiResponse = httpService.getRequest(url);
String responseData = apiResponse.get("data");
LOGGER.info("Response Data: {}", responseData);
// Update outbound log with response
helper.updateOutboundLogResponse(outboundLog, responseData);
// Update outbound log with response
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
if (!dataMap.containsKey("generalResp")) {
// Failure response
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
String.valueOf(dataMap.get("remarks")));
}
if (!dataMap.containsKey("generalResp")) {
// Failure response
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
throw new CustomException(
String.valueOf(dataMap.get("message")),
String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
String.valueOf(dataMap.get("remarks"))
);
}
// Success response
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
// Success response
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
ResponseModel responseModel = new ResponseModel(
generalResp.getMessage(),
generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()),
responseWrapper
);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
return responseModel;
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");
}
} 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");
}
}
}