12-11-25
This commit is contained in:
@@ -42,7 +42,9 @@ public class BBPSConstant {
|
||||
public static final String PAYMENT_URL = "/agent/bills/payment";
|
||||
public static final String CHECK_TRANSACTION_URL = "/transactions/payment/byTxnId?txnId=";
|
||||
public static final String DISPOSTION_URL = "/disposition";
|
||||
|
||||
public static final String COMPALINT_STATUS = "/couapp/complaints/status";
|
||||
public static final String REOPEN_COMPALINT = "/couapp/complaints/reopen";
|
||||
|
||||
public static final String PLANS_URL = "/plans";
|
||||
|
||||
}
|
||||
|
||||
@@ -6,32 +6,41 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.modelmapper.ModelMapper;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.AmountOptionDTO;
|
||||
import com.billpaymentservice.bbps.dto.BillerIconDTO;
|
||||
import com.billpaymentservice.bbps.dto.ComplainDetailsDto;
|
||||
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
|
||||
import com.billpaymentservice.bbps.dto.GroupDTO;
|
||||
import com.billpaymentservice.bbps.dto.MasterCategoryBillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.PlanDTO;
|
||||
import com.billpaymentservice.bbps.dto.PlanTag;
|
||||
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.PlanResponse;
|
||||
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
|
||||
import com.billpaymentservice.bbps.entites.AmountOptionDetails;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryIcon;
|
||||
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
|
||||
import com.billpaymentservice.bbps.entites.CategoryResponseList;
|
||||
import com.billpaymentservice.bbps.entites.ComplainStatus;
|
||||
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
|
||||
import com.billpaymentservice.bbps.entites.FetchBillValidate;
|
||||
import com.billpaymentservice.bbps.entites.GroupParam;
|
||||
import com.billpaymentservice.bbps.entites.Plan;
|
||||
import com.billpaymentservice.bbps.entites.PlanCategorySubType;
|
||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||
import com.billpaymentservice.bbps.entites.PlansList;
|
||||
import com.billpaymentservice.bbps.entites.ReOpenComplain;
|
||||
import com.billpaymentservice.bbps.repository.AmountOptionByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.BillerCategoryWiseRepository;
|
||||
import com.billpaymentservice.bbps.repository.CategoryResponseListRepository;
|
||||
import com.billpaymentservice.bbps.repository.ComplaintStatusRepository;
|
||||
import com.billpaymentservice.bbps.repository.CustomerParamGroupByBillerIdRepository;
|
||||
import com.billpaymentservice.bbps.repository.FetchBillValidateRepository;
|
||||
import com.billpaymentservice.bbps.repository.PlanResponseRepository;
|
||||
import com.billpaymentservice.bbps.repository.ReOpenComplaintRepository;
|
||||
|
||||
@Component
|
||||
public class BillerMapperHelper {
|
||||
@@ -42,19 +51,24 @@ public class BillerMapperHelper {
|
||||
private final PlanResponseRepository planResponseRepository;
|
||||
private final CategoryResponseListRepository categoryResponseListRepository;
|
||||
private final FetchBillValidateRepository fetchBillValidateRepository;
|
||||
private final ComplaintStatusRepository complaintStatusRepository;
|
||||
private final ReOpenComplaintRepository reOpenComplaintRepository;
|
||||
|
||||
public BillerMapperHelper(BillerCategoryWiseRepository billerRepo,
|
||||
CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo,
|
||||
AmountOptionByBillerIdRepository amountOptionByBillerIdRepository,
|
||||
PlanResponseRepository planResponseRepository,
|
||||
CategoryResponseListRepository categoryResponseListRepository,
|
||||
FetchBillValidateRepository fetchBillValidateRepository) {
|
||||
FetchBillValidateRepository fetchBillValidateRepository,
|
||||
ComplaintStatusRepository complaintStatusRepository, ReOpenComplaintRepository reOpenComplaintRepository) {
|
||||
this.billerRepo = billerRepo;
|
||||
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
|
||||
this.amountOptionByBillerIdRepository = amountOptionByBillerIdRepository;
|
||||
this.planResponseRepository = planResponseRepository;
|
||||
this.categoryResponseListRepository = categoryResponseListRepository;
|
||||
this.fetchBillValidateRepository = fetchBillValidateRepository;
|
||||
this.complaintStatusRepository = complaintStatusRepository;
|
||||
this.reOpenComplaintRepository = reOpenComplaintRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -273,22 +287,73 @@ public class BillerMapperHelper {
|
||||
})).collect(Collectors.toList()); // Collect them into a list and return
|
||||
}
|
||||
|
||||
public PlanResponses savePlanResponse(PlanResponse planResponseDTO, String requestId, String txnId) {
|
||||
public PlanResponses savePlanResponse(PlanResponse planResponse, String reqId, String txnId) {
|
||||
PlanResponses response = new PlanResponses();
|
||||
response.setRequestId(reqId);
|
||||
response.setPageNo(planResponse.getPageNo());
|
||||
response.setPageSize(planResponse.getPageSize());
|
||||
response.setTotalElements(planResponse.getTotalElements());
|
||||
response.setTotalPages(planResponse.getTotalPages());
|
||||
response.setTxnId(txnId);
|
||||
response.setCreateDateTime(new Date());
|
||||
|
||||
// If the list is null or empty, return an empty list of entities
|
||||
if (planResponseDTO == null) {
|
||||
return new PlanResponses(); // Return an empty list of AmountOptionDetails
|
||||
}
|
||||
PlansList plansList = new PlansList();
|
||||
List<Plan> planEntities = new ArrayList<>();
|
||||
|
||||
// Convert DTO to Entity using ModelMapper
|
||||
ModelMapper modelMapper = new ModelMapper();
|
||||
PlanResponses planResponseEntity = modelMapper.map(planResponseDTO, PlanResponses.class);
|
||||
// Save the entity to the database
|
||||
// Set the requestId and txnId in the entity
|
||||
planResponseEntity.setRequestId(requestId);
|
||||
planResponseEntity.setTxnId(txnId);
|
||||
planResponseEntity.setCreateDateTime(new Date());
|
||||
return planResponseRepository.save(planResponseEntity);
|
||||
for (PlanDTO dto : planResponse.getPlansList().getPlans()) {
|
||||
Plan plan = new Plan();
|
||||
plan.setPlanId(dto.getPlanId());
|
||||
plan.setDescription(dto.getDescription());
|
||||
plan.setBillerId(dto.getBillerId());
|
||||
plan.setCategoryType(dto.getCategoryType());
|
||||
plan.setAmountInRupees(dto.getAmountInRupees());
|
||||
plan.setEffctvFrom(dto.getEffctvFrom());
|
||||
plan.setEffctvTo(dto.getEffctvTo());
|
||||
plan.setStatus(dto.getStatus());
|
||||
plan.setPlansList(plansList);
|
||||
|
||||
// categorySubType
|
||||
List<PlanCategorySubType> subs = new ArrayList<>();
|
||||
if (dto.getCategorySubType() != null) {
|
||||
for (String s : dto.getCategorySubType()) {
|
||||
PlanCategorySubType sub = new PlanCategorySubType();
|
||||
sub.setCategorySubType(s);
|
||||
sub.setPlan(plan);
|
||||
subs.add(sub);
|
||||
}
|
||||
}
|
||||
plan.setCategorySubTypes(subs);
|
||||
|
||||
// additionalInfo + tags
|
||||
// ✅ additionalInfo + tags
|
||||
if (dto.getAdditionalInfo() != null) {
|
||||
AdditionalInfoPlans info = new AdditionalInfoPlans();
|
||||
info.setPlanAdditionalInfoId(dto.getAdditionalInfo().getPlanAdditionalInfoId().toString());
|
||||
|
||||
List<com.billpaymentservice.bbps.entites.PlanTag> tagEntities = new ArrayList<>();
|
||||
if (dto.getAdditionalInfo().getTags() != null && !dto.getAdditionalInfo().getTags().isEmpty()) {
|
||||
for (com.billpaymentservice.bbps.dto.PlanTag tagDto : dto.getAdditionalInfo().getTags()) {
|
||||
com.billpaymentservice.bbps.entites.PlanTag tagEntity = new com.billpaymentservice.bbps.entites.PlanTag();
|
||||
tagEntity.setTagId(tagDto.getTagId().toString());
|
||||
tagEntity.setName(tagDto.getName());
|
||||
tagEntity.setValue(tagDto.getValue());
|
||||
tagEntity.setAdditionalInfo(info); // ✅ maintain relationship
|
||||
tagEntities.add(tagEntity);
|
||||
}
|
||||
}
|
||||
|
||||
// ✅ Now set the entity list
|
||||
info.setTags(tagEntities);
|
||||
plan.setAdditionalInfo(info);
|
||||
}
|
||||
|
||||
planEntities.add(plan);
|
||||
}
|
||||
|
||||
plansList.setPlans(planEntities);
|
||||
response.setPlansList(plansList);
|
||||
|
||||
return planResponseRepository.save(response);
|
||||
}
|
||||
|
||||
public String saveCategoryItems(List<String> categoryRespList, String requestId, String txnId) {
|
||||
@@ -310,30 +375,104 @@ public class BillerMapperHelper {
|
||||
return savedCount + " items were successfully saved.";
|
||||
}
|
||||
|
||||
/*
|
||||
* public FetchBillValidate
|
||||
* saveFetchBillValidateResponse(FetchBillValidateResponse dto, String
|
||||
* requestId, String txnId) {
|
||||
*
|
||||
* if (dto == null) { return new FetchBillValidate(); }
|
||||
*
|
||||
* // Convert DTO to Entity FetchBillValidate entity = new FetchBillValidate();
|
||||
*
|
||||
* entity.setBillId(dto.getBillId()); entity.setRefId(dto.getRefId());
|
||||
* entity.setBillerId(dto.getBillerId()); entity.setStatus(dto.getStatus());
|
||||
* entity.setActionType(dto.getActionType()); entity.setUserId(dto.getUserId());
|
||||
* entity.setBillerResponse(dto.getBillerResponse());
|
||||
* entity.setAdditionalInfo(dto.getAdditionalInfo());
|
||||
* entity.setCustomerParams(dto.getCustomerParams());
|
||||
* entity.setPlanInfoDaos(dto.getPlanInfoDaos());
|
||||
* entity.setCreationDate(dto.getCreationDate());
|
||||
* entity.setModifiedDate(dto.getModifiedDate());
|
||||
* entity.setCreatedEpochDate(dto.getCreatedEpochDate());
|
||||
* entity.setModifiedEpochDate(dto.getModifiedEpochDate());
|
||||
* entity.setRequestId(requestId); entity.setTxnId(txnId);
|
||||
* entity.setCreateDateTime(new Date());
|
||||
*
|
||||
* // Save the entity in the database return
|
||||
* fetchBillValidateRepository.save(entity); }
|
||||
*/
|
||||
public String saveComplaintStatus(ComplaintStatusResponse response, String reqId) {
|
||||
|
||||
if (response == null || response.getComplaints() == null) {
|
||||
throw new IllegalArgumentException("Invalid complaint response received!");
|
||||
}
|
||||
|
||||
ComplainDetailsDto dto = response.getComplaints();
|
||||
|
||||
// ✅ Create and populate entity
|
||||
ComplainStatus entity = new ComplainStatus();
|
||||
entity.setComplaintId(dto.getComplaintId());
|
||||
entity.setComplaintDescr(dto.getComplaintDescr());
|
||||
entity.setComplaintDispos(dto.getComplaintDispos());
|
||||
entity.setComplaintType(dto.getComplaintType());
|
||||
entity.setTxnId(dto.getTxnId());
|
||||
entity.setComplaintStatus(dto.getComplaintStatus());
|
||||
entity.setAssignedTo(dto.getAssignedTo());
|
||||
entity.setComplaintNpciId(dto.getComplaintNpciId());
|
||||
entity.setComplaintRaisedFrom(dto.getComplaintRaisedFrom());
|
||||
entity.setUserId(dto.getUserId());
|
||||
entity.setStatus(dto.getStatus());
|
||||
entity.setRefId(dto.getRefId());
|
||||
entity.setEstimatedTAT(dto.getEstimated_TAT()); // ✅ added missing field
|
||||
entity.setCreationDate(dto.getCreationDate());
|
||||
entity.setModifiedDate(dto.getModifiedDate());
|
||||
entity.setBillerName(dto.getBillerName());
|
||||
entity.setTxnAmount(dto.getTxnAmount());
|
||||
entity.setSuperLevelEsc(dto.getSuperLevelEsc());
|
||||
entity.setOpenComplaint(dto.getOpenComplaint());
|
||||
entity.setReopenComplaint(dto.getReopenComplaint());
|
||||
entity.setRemarks(dto.getRemarks());
|
||||
entity.setAgentId(dto.getAgentId());
|
||||
entity.setCategory(dto.getCategory());
|
||||
entity.setCreatedEpochDate(dto.getCreatedEpochDate());
|
||||
entity.setModifiedEpochDate(dto.getModifiedEpochDate());
|
||||
entity.setRefId(reqId);
|
||||
|
||||
try {
|
||||
ComplainStatus savedEntity = complaintStatusRepository.save(entity);
|
||||
if (savedEntity != null && savedEntity.getId() != null) {
|
||||
return "Complaint saved successfully with ID: " + savedEntity.getId();
|
||||
} else {
|
||||
return " Complaint not saved — unexpected error!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " Error saving complaint: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public String saveReOpenComplaint(ComplaintStatusResponse response, String reqId) {
|
||||
|
||||
if (response == null || response.getComplaints() == null) {
|
||||
throw new IllegalArgumentException("Invalid complaint response received!");
|
||||
}
|
||||
|
||||
ComplainDetailsDto dto = response.getComplaints();
|
||||
|
||||
// ✅ Create and populate entity
|
||||
ReOpenComplain entity = new ReOpenComplain();
|
||||
entity.setComplaintId(dto.getComplaintId());
|
||||
entity.setComplaintDescr(dto.getComplaintDescr());
|
||||
entity.setComplaintDispos(dto.getComplaintDispos());
|
||||
entity.setComplaintType(dto.getComplaintType());
|
||||
entity.setTxnId(dto.getTxnId());
|
||||
entity.setComplaintStatus(dto.getComplaintStatus());
|
||||
entity.setAssignedTo(dto.getAssignedTo());
|
||||
entity.setComplaintNpciId(dto.getComplaintNpciId());
|
||||
entity.setComplaintRaisedFrom(dto.getComplaintRaisedFrom());
|
||||
entity.setUserId(dto.getUserId());
|
||||
entity.setStatus(dto.getStatus());
|
||||
entity.setRefId(dto.getRefId());
|
||||
entity.setEstimatedTAT(dto.getEstimated_TAT()); // ✅ added missing field
|
||||
entity.setCreationDate(dto.getCreationDate());
|
||||
entity.setModifiedDate(dto.getModifiedDate());
|
||||
entity.setBillerName(dto.getBillerName());
|
||||
entity.setTxnAmount(dto.getTxnAmount());
|
||||
entity.setSuperLevelEsc(dto.getSuperLevelEsc());
|
||||
entity.setOpenComplaint(dto.getOpenComplaint());
|
||||
entity.setReopenComplaint(dto.getReopenComplaint());
|
||||
entity.setRemarks(dto.getRemarks());
|
||||
entity.setAgentId(dto.getAgentId());
|
||||
entity.setCategory(dto.getCategory());
|
||||
entity.setCreatedEpochDate(dto.getCreatedEpochDate());
|
||||
entity.setModifiedEpochDate(dto.getModifiedEpochDate());
|
||||
entity.setRefId(reqId);
|
||||
|
||||
try {
|
||||
ReOpenComplain savedEntity = reOpenComplaintRepository.save(entity);
|
||||
if (savedEntity != null && savedEntity.getId() != null) {
|
||||
return "ReOpen Complaint saved successfully with ID: " + savedEntity.getId();
|
||||
} else {
|
||||
return " ReOpen Complaint not saved — unexpected error!";
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return " Error saving complaint: " + e.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user