04-11-25
This commit is contained in:
@@ -19,6 +19,7 @@ import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerDataResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.BillerResponse;
|
||||
@@ -26,6 +27,7 @@ import com.billpaymentservice.bbps.dto.response.ChannelsListResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.CustomParamResp;
|
||||
import com.billpaymentservice.bbps.dto.response.CustomerParamGroupsResponse;
|
||||
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.BillerDetails;
|
||||
@@ -79,13 +81,24 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.info("Request DTO: {}", masterRequest);
|
||||
|
||||
try {
|
||||
// Merchant Validation
|
||||
helper.validateMerchant(masterRequest.getMid());
|
||||
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
// check Tender Id is present DB
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
log.info("ResPONSE" + headersData);
|
||||
log.info("Response -: " + headersData);
|
||||
if (headersData == null) {
|
||||
ResponseModel responseModel = new ResponseModel("Tenant Id Is Null", "Not Found",
|
||||
BBPSConstant.BADREQUEST, headersData);
|
||||
return responseModel;
|
||||
}
|
||||
|
||||
// get full url
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
|
||||
@@ -118,22 +131,33 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ex) {
|
||||
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
||||
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
||||
|
||||
String billerId = billerDetailRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
log.info("data is :{}", responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
|
||||
helper.validateMerchant(billerDetailRequest.getMid());
|
||||
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String billerId = billerDetailRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
log.info("data is :{}", responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
@@ -157,6 +181,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ex) {
|
||||
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
||||
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,6 +191,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
||||
|
||||
try {
|
||||
helper.validateMerchant(customerParamRequest.getMid());
|
||||
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String billerId = customerParamRequest.getBillerId();
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
|
||||
@@ -194,6 +227,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ex) {
|
||||
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
||||
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
||||
}
|
||||
|
||||
}
|
||||
@@ -201,21 +237,20 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
@Override
|
||||
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
||||
|
||||
// yeh krna hai
|
||||
return new ResponseModel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
||||
LOGGER.info("Fetching Master Data Category-wise " + masterRequest);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(masterRequest.getMid());
|
||||
|
||||
String validateMerchant = helper.validateMerchant(masterRequest);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
||||
@@ -250,19 +285,23 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ex) {
|
||||
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
||||
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getDispositionDetails() {
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
@@ -296,6 +335,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ex) {
|
||||
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
||||
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
||||
}
|
||||
|
||||
}
|
||||
@@ -305,13 +347,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.info("Fetching Master Data Category-wise for MID={}", requestModel.getMid());
|
||||
|
||||
try {
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
||||
// LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
@@ -341,6 +382,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException ex) {
|
||||
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
||||
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
||||
}
|
||||
|
||||
}
|
||||
@@ -349,12 +393,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Master Data Amount List for MID={}", requestModel.getMid());
|
||||
try {
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
||||
// LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
@@ -389,18 +433,19 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
LOGGER.error("Custom Exception: {}", e.getMessage());
|
||||
throw e; // Rethrow custom exceptions to be handled by the controller
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Master Data Amount List for MID={}", requestModel.getMid());
|
||||
try {
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
|
||||
// LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
@@ -441,12 +486,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
||||
LOGGER.info("Fetching Initiating Channel List for MID={}", requestModel.getMid());
|
||||
try {
|
||||
String validateMerchant = helper.validateMerchant(requestModel);
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
||||
LOGGER.info("Calling Master API: {}", fullUrl);
|
||||
@@ -483,4 +528,58 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
|
||||
LOGGER.info("Fetching Initiating Fetch Plan Category By Bidder Id for MID={}", requestModel.getMid());
|
||||
try {
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
|
||||
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
||||
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
||||
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
||||
// }
|
||||
|
||||
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 fullUrl = masterRegisterUrl + BBPSConstant.PLANS_URL + url;
|
||||
LOGGER.info("Calling Master API: {}", url);
|
||||
|
||||
Map<String, String> apiResponse = httpService.getRequest(url);
|
||||
log.info("Response" + apiResponse);
|
||||
String responseData = apiResponse.get("data").toString();
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
||||
String.valueOf(dataMap.get("status")), // status
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
||||
String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
} catch (CustomException e) {
|
||||
LOGGER.error("Custom Exception: {}", e.getMessage());
|
||||
throw e; // Rethrow custom exceptions to be handled by the controller
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user