update code complaint code

This commit is contained in:
Mohd-Arham
2025-11-21 09:54:43 +05:30
parent 1aedfd890d
commit 32a42284f8
54 changed files with 1907 additions and 1189 deletions
@@ -41,14 +41,17 @@ public class BBPSConstant {
public static final String BILL_FETCH_BY_ID = "/couapp/bills/fetch/byId?billId=";
public static final String PAYMENT_URL = "/agent/bills/payment";
public static final String CHECK_TRANSACTION_URL = "/transactions/payment/byTxnId?txnId=";
public static final String CHECK_TRANSACTION_BY_CLIENT_URL = "/bills/fetch/byClientId?clientReqId=";
public static final String DISPOSTION_URL = "/disposition";
public static final String COMPALINT_STATUS = "/couapp/complaints/status";
public static final String TICKET_DISPOSTION_URL = "/ticket-disposition";
public static final String COMPALINT_STATUS = "/couapp/ticket/status";
public static final String REOPEN_COMPALINT = "/couapp/complaints/reopen";
public static final String COMPLAINT_HISTORY = "/couapp/complaints/history/byId?complaintId=";
public static final String COMPLAINT_HISTORY = "/couapp/ticket/history?ticketId=";
public static final String CLOSE_COMPLAINT = "/couapp/complaints/closure";
public static final String VIEW_COMPLAINT_BY_ID = "/couapp/complaints/byId?complaintId=";
public static final String VIEW_COMPLAINT_BY_ID = "/couapp/ticket/details?ticketId=";
public static final String PLANS_URL = "/plans";
public static final String ADD_COMPLAIN_ENDPOINT = "/couapp/complaints";
public static final String ADD_COMPLAIN_ENDPOINT = "/couapp/ticket/raise";
public static final String VIEW_ALL_COMPLAINTS_BASE = "/couapp/tickets";
}
@@ -15,26 +15,37 @@ import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.billpaymentservice.bbps.dto.AmountOptionDTO;
import com.billpaymentservice.bbps.dto.BillAdditionalInfoDTO;
import com.billpaymentservice.bbps.dto.BillCustomerParamsDTO;
import com.billpaymentservice.bbps.dto.BillerIconDTO;
import com.billpaymentservice.bbps.dto.ComplainDetailsDto;
import com.billpaymentservice.bbps.dto.CheckClientBillerResponseDTO;
import com.billpaymentservice.bbps.dto.ComplaintHistoryDTO;
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
import com.billpaymentservice.bbps.dto.Detail;
import com.billpaymentservice.bbps.dto.GroupDTO;
import com.billpaymentservice.bbps.dto.MasterCategoryBillerResponse;
import com.billpaymentservice.bbps.dto.PlanDTO;
import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
import com.billpaymentservice.bbps.dto.TicketDispositionsDTO;
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
import com.billpaymentservice.bbps.dto.response.ComplaintStatusResponse;
import com.billpaymentservice.bbps.dto.response.PlanResponse;
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
import com.billpaymentservice.bbps.entites.AmountOptionByBillerId;
import com.billpaymentservice.bbps.entites.AmountOptionDetails;
import com.billpaymentservice.bbps.entites.BillAdditionalInfo;
import com.billpaymentservice.bbps.entites.BillCustomerParams;
import com.billpaymentservice.bbps.entites.BillTag;
import com.billpaymentservice.bbps.entites.BillerCategoryIcon;
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
import com.billpaymentservice.bbps.entites.CategoryResponseList;
import com.billpaymentservice.bbps.entites.CheckClientBillerData;
import com.billpaymentservice.bbps.entites.CheckClientStatusReqId;
import com.billpaymentservice.bbps.entites.ComplainStatus;
import com.billpaymentservice.bbps.entites.ComplaintDetails;
import com.billpaymentservice.bbps.entites.ComplaintHistory;
import com.billpaymentservice.bbps.entites.ComplaintStatusDetails;
import com.billpaymentservice.bbps.entites.CustomerParamGroupById;
@@ -43,19 +54,23 @@ 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.entites.TicketDispositionDetails;
import com.billpaymentservice.bbps.entites.ViewAllComplaintTicketStatusDetails;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.AmountOptionByBillerIdRepository;
import com.billpaymentservice.bbps.repository.BillerCategoryWiseRepository;
import com.billpaymentservice.bbps.repository.CategoryResponseListRepository;
import com.billpaymentservice.bbps.repository.CheckClientBillerDataRepository;
import com.billpaymentservice.bbps.repository.ClientReqIdRepository;
import com.billpaymentservice.bbps.repository.ComplainDetailRepository;
import com.billpaymentservice.bbps.repository.ComplaintHistoryRepository;
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;
import com.billpaymentservice.bbps.repository.ComplainDetailRepository;
import com.billpaymentservice.bbps.serviceImpl.AgentServiceImpl;
import com.billpaymentservice.bbps.repository.TicketDispositionRepository;
import com.billpaymentservice.bbps.repository.ViewAllComplainTicketDetailRepository;
@Component
public class BillerMapperHelper {
@@ -66,13 +81,16 @@ public class BillerMapperHelper {
private final CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo;
private final AmountOptionByBillerIdRepository amountOptionByBillerIdRepository;
private final PlanResponseRepository planResponseRepository;
private final TicketDispositionRepository ticketDispositionRepository;
private final CategoryResponseListRepository categoryResponseListRepository;
private final FetchBillValidateRepository fetchBillValidateRepository;
private final ComplaintStatusRepository complaintStatusRepository;
private final ReOpenComplaintRepository reOpenComplaintRepository;
private final ComplaintHistoryRepository complaintHistoryRepository;
private final ClientReqIdRepository clientReqIdRepository;
private final ComplainDetailRepository complainDetailRepository;
private final CheckClientBillerDataRepository checkClientBillerDataRepository;
private final ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository;
public BillerMapperHelper(BillerCategoryWiseRepository billerRepo,
CustomerParamGroupByBillerIdRepository customerParamGroupByBillerIdRepo,
@@ -81,8 +99,11 @@ public class BillerMapperHelper {
CategoryResponseListRepository categoryResponseListRepository,
FetchBillValidateRepository fetchBillValidateRepository,
ComplaintStatusRepository complaintStatusRepository, ReOpenComplaintRepository reOpenComplaintRepository,
ComplaintHistoryRepository complaintHistoryRepository,
ComplainDetailRepository complainDetailRepository) {
ComplaintHistoryRepository complaintHistoryRepository, ComplainDetailRepository complainDetailRepository,
ClientReqIdRepository clientReqIdRepository,
CheckClientBillerDataRepository checkClientBillerDataRepository,
TicketDispositionRepository ticketDispositionRepository,
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository) {
this.billerRepo = billerRepo;
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
this.amountOptionByBillerIdRepository = amountOptionByBillerIdRepository;
@@ -93,6 +114,10 @@ public class BillerMapperHelper {
this.reOpenComplaintRepository = reOpenComplaintRepository;
this.complaintHistoryRepository = complaintHistoryRepository;
this.complainDetailRepository = complainDetailRepository;
this.clientReqIdRepository = clientReqIdRepository;
this.checkClientBillerDataRepository = checkClientBillerDataRepository;
this.ticketDispositionRepository = ticketDispositionRepository;
this.viewAllComplainTicketDetailRepository = viewAllComplainTicketDetailRepository;
}
/**
@@ -399,140 +424,75 @@ public class BillerMapperHelper {
return savedCount + " items were successfully saved.";
}
public String saveComplaintStatus(ComplaintStatusResponse response, String reqId, String txnId) {
public String saveComplaintStatus(TicketCheckStatusResponse response, String reqId, String txnId) {
if (response == null || response.getComplaints() == null) {
throw new IllegalArgumentException("Invalid complaint response received!");
if (response == null || response.getTicketDetails() == null) {
throw new CustomException("Invalid response received!", "FAILURE", 500, "Response Null");
}
ComplainDetailsDto dto = response.getComplaints();
// ✔ Validate HTTP style statusCode
if (!"200".equals(response.getStatusCode())) {
throw new CustomException(response.getMessage(), response.getStatus(),
Integer.parseInt(response.getStatusCode()), response.getRemarks());
}
// ✅ Create and populate entity
TicketDetailsDTO dto = response.getTicketDetails();
if (dto == null) {
throw new CustomException("Ticket details missing!", "FAILURE", 500, "Invalid Data");
}
// ✔ Check if already exists
// if (complaintStatusRepository.existsByTicketId(dto.getTicketId())) {
// return "Complaint already exists in DB. TicketId: " + dto.getTicketId();
// }
// ✔ Create 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.setRefId(response.getRefId());
entity.setReqId(reqId);
entity.setTxnId(txnId);
entity.setTicketId(dto.getTicketId());
entity.setTicketNpciId(dto.getTicketNpciId());
entity.setTxnNpciId(dto.getTxnNpciId());
entity.setTicketType(dto.getTicketType());
entity.setTicketDespo(dto.getTicketDespo());
entity.setTicketDescr(dto.getTicketDescr());
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);
entity.setSystemTxnId(txnId);
entity.setNpciTicketType(dto.getNpciTicketType());
entity.setNpciTicketStatus(dto.getNpciTicketStatus());
entity.setCreatedTime(dto.getCreatedTime());
entity.setCreateDateTime(new Date());
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!";
}
ComplainStatus saved = complaintStatusRepository.save(entity);
return "Complaint saved successfully with ID: " + saved.getId();
} catch (Exception e) {
e.printStackTrace();
return " Error saving complaint: " + e.getMessage();
}
}
public String saveReOpenComplaint(ComplaintStatusResponse response, String reqId, String txnId) {
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);
entity.setSystemTxnId(txnId);
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();
return "Error saving complaint: " + e.getMessage();
}
}
public String saveComplaintHistory(ComplaintHistoryStatusResponse responseWrapper, String reqId, String txnId) {
if (responseWrapper == null || responseWrapper.getComplaintsHistories() == null
|| responseWrapper.getComplaintsHistories().isEmpty()) {
if (responseWrapper == null || responseWrapper.getTicketHistories() == null
|| responseWrapper.getTicketHistories().isEmpty()) {
return "No complaint history data found to save.";
}
try {
int savedCount = 0;
for (ComplaintHistoryDTO dto : responseWrapper.getComplaintsHistories()) {
for (ComplaintHistoryDTO dto : responseWrapper.getTicketHistories()) {
ComplaintHistory entity = new ComplaintHistory();
entity.setComplaintHistoryId(dto.getComplaintHistoryId());
entity.setComplaintId(dto.getComplaintId());
entity.setComplaintDescr(dto.getComplaintDescr());
entity.setComplaintDispos(dto.getComplaintDispos());
entity.setTxnId(dto.getTxnId());
entity.setAssignedTo(dto.getAssignedTo());
entity.setComplaintNpciId(dto.getComplaintNpciId());
entity.setComplaintType(dto.getComplaintType());
entity.setComplaintRaisedFrom(dto.getComplaintRaisedFrom());
entity.setUserId(dto.getUserId());
entity.setStatus(dto.getStatus());
entity.setModifiedDate(dto.getModifiedDate());
entity.setModifiedEpochDate(dto.getModifiedEpochDate());
entity.setHistoryId(dto.getHistoryId());
entity.setTicketId(dto.getTicketId());
entity.setTime(dto.getTime());
entity.setHistoryStatus(dto.getHistoryStatus());
entity.setReqId(reqId);
entity.setSystemTxnId(txnId);
entity.setTxnId(txnId);
entity.setCreateDateTime(new Date());
entity.setPageNo(responseWrapper.getPageNo());
entity.setPageSize(responseWrapper.getPageSize());
entity.setTotalElements(responseWrapper.getTotalElements());
entity.setTotalPages(responseWrapper.getTotalPages());
complaintHistoryRepository.save(entity);
savedCount++;
@@ -546,116 +506,271 @@ public class BillerMapperHelper {
return "❌ Failed to save complaint history data due to: " + e.getMessage();
}
}
public Map<String, Object> getComplaintStatusJson() {
Map<String, Object> complaints = new HashMap<>();
complaints.put("assignedTo", "XYZ Bank");
complaints.put("complaintDescr", "Testing complaint");
complaints.put("complaintDispos", "Transaction Successful, account not updated");
complaints.put("complaintId", "2dfecc3c-9114-4094-9aa8-ff26f03a9bfd");
complaints.put("complaintNpciId", "FE4123109489834");
complaints.put("complaintRaisedFrom", "agent");
complaints.put("complaintType", "npciComplaint");
complaints.put("createdEpochDate", 1681905485);
complaints.put("creationDate", "2023-04-19T17:28:05.508679Z");
complaints.put("modifiedDate", "2023-04-19T17:28:10.001432Z");
complaints.put("modifiedEpochDate", 1681905490);
complaints.put("refId", "mqcXfZs2XMkRKQfpIwoSYQDnIr231091728");
complaints.put("status", "COMPLAINT_OPEN_SUCCESS");
complaints.put("tenantId", "FE41");
complaints.put("txnId", "24fe190c-42c9-4cb5-9d36-965839b0cb5f");
complaints.put("txnNpciId", "FE4131090DAI26Y0mAxl");
complaints.put("userId", "FE41FE42BNK519012345");
complaints.put("agentId", "FE41FE42BNK519012345");
Map<String, Object> complaints = new HashMap<>();
complaints.put("assignedTo", "XYZ Bank");
complaints.put("complaintDescr", "Testing complaint");
complaints.put("complaintDispos", "Transaction Successful, account not updated");
complaints.put("complaintId", "2dfecc3c-9114-4094-9aa8-ff26f03a9bfd");
complaints.put("complaintNpciId", "FE4123109489834");
complaints.put("complaintRaisedFrom", "agent");
complaints.put("complaintType", "npciComplaint");
complaints.put("createdEpochDate", 1681905485);
complaints.put("creationDate", "2023-04-19T17:28:05.508679Z");
complaints.put("modifiedDate", "2023-04-19T17:28:10.001432Z");
complaints.put("modifiedEpochDate", 1681905490);
complaints.put("refId", "mqcXfZs2XMkRKQfpIwoSYQDnIr231091728");
complaints.put("status", "COMPLAINT_OPEN_SUCCESS");
complaints.put("tenantId", "FE41");
complaints.put("txnId", "24fe190c-42c9-4cb5-9d36-965839b0cb5f");
complaints.put("txnNpciId", "FE4131090DAI26Y0mAxl");
complaints.put("userId", "FE41FE42BNK519012345");
complaints.put("agentId", "FE41FE42BNK519012345");
Map<String, Object> finalJson = new HashMap<>();
finalJson.put("complaints", complaints);
Map<String, Object> finalJson = new HashMap<>();
finalJson.put("complaints", complaints);
return finalJson;
return finalJson;
}
public Map<String, Object> getDummyReopenComplaintJson() {
Map<String, Object> complaints = new HashMap<>();
complaints.put("assignedTo", "Federal Bank");
complaints.put("complaintDescr", "Issue not yet solved - reopening");
complaints.put("complaintDispos", "Transaction Successful, account not updated");
complaints.put("complaintId", "809ec4c7-d81b-4d2b-9c66-3011a6fae714");
complaints.put("complaintNpciId", "FE4123109776644");
complaints.put("complaintRaisedFrom", "agent");
complaints.put("complaintType", "npciComplaint");
complaints.put("createdEpochDate", 1681893776);
complaints.put("creationDate", "2023-04-19T14:12:56.329935Z");
complaints.put("modifiedDate", "2023-04-19T14:19:44.891423Z");
complaints.put("modifiedEpochDate", 1681894184);
complaints.put("refId", "7sQwBamvWFyLxhK84dYgGmV24r831091419");
complaints.put("status", "COMPLAINT_REOPEN_SUCCESS");
complaints.put("tenantId", "FE41");
complaints.put("txnId", "155a4a71-141f-40fd-b772-9d0e020963e8");
complaints.put("txnNpciId", "FE413045Hl3L90ZWg59o");
complaints.put("userId", "FE41FE42BNK519012345");
complaints.put("agentId", "FE41FE42BNK519012345");
Map<String, Object> complaints = new HashMap<>();
complaints.put("assignedTo", "Federal Bank");
complaints.put("complaintDescr", "Issue not yet solved - reopening");
complaints.put("complaintDispos", "Transaction Successful, account not updated");
complaints.put("complaintId", "809ec4c7-d81b-4d2b-9c66-3011a6fae714");
complaints.put("complaintNpciId", "FE4123109776644");
complaints.put("complaintRaisedFrom", "agent");
complaints.put("complaintType", "npciComplaint");
complaints.put("createdEpochDate", 1681893776);
complaints.put("creationDate", "2023-04-19T14:12:56.329935Z");
complaints.put("modifiedDate", "2023-04-19T14:19:44.891423Z");
complaints.put("modifiedEpochDate", 1681894184);
complaints.put("refId", "7sQwBamvWFyLxhK84dYgGmV24r831091419");
complaints.put("status", "COMPLAINT_REOPEN_SUCCESS");
complaints.put("tenantId", "FE41");
complaints.put("txnId", "155a4a71-141f-40fd-b772-9d0e020963e8");
complaints.put("txnNpciId", "FE413045Hl3L90ZWg59o");
complaints.put("userId", "FE41FE42BNK519012345");
complaints.put("agentId", "FE41FE42BNK519012345");
Map<String, Object> finalJson = new HashMap<>();
finalJson.put("complaints", complaints);
return finalJson;
Map<String, Object> finalJson = new HashMap<>();
finalJson.put("complaints", complaints);
return finalJson;
}
public Map<String, Object> getDummyClosureComplaintJson() {
Map<String, Object> complaints = new HashMap<>();
complaints.put("complaintDescr", "Closing complaint Issue resolved");
complaints.put("complaintDispos", "Transaction Successful, account not updated");
complaints.put("complaintId", "809ec4c7-d81b-4d2b-9c66-3011a6fae714");
complaints.put("complaintNpciId", "FE4123109776644");
complaints.put("complaintRaisedFrom", "agent");
complaints.put("complaintType", "npciComplaint");
complaints.put("createdEpochDate", 1681893776);
complaints.put("creationDate", "2023-04-19T14:12:56.329935Z");
complaints.put("modifiedDate", "2023-04-19T14:13:32.25255Z");
complaints.put("modifiedEpochDate", 1681893812);
complaints.put("refId", "hHfEKYZExIpxNEV65HMQZ2Lh0DA31091413");
complaints.put("status", "COMPLAINT_CLOSURE_REQUEST_SUCCESS"); // removed spaces
complaints.put("tenantId", "FE41");
complaints.put("txnId", "155a4a71-141f-40fd-b772-9d0e020963e8");
complaints.put("txnNpciId", "FE413045Hl3L90ZWg59o");
complaints.put("userId", "FE41FE42BNK519012345");
complaints.put("agentId", "FE41FE42BNK519012345");
Map<String, Object> finalJson = new HashMap<>();
finalJson.put("complaints", complaints);
Map<String, Object> complaints = new HashMap<>();
complaints.put("complaintDescr", "Closing complaint Issue resolved");
complaints.put("complaintDispos", "Transaction Successful, account not updated");
complaints.put("complaintId", "809ec4c7-d81b-4d2b-9c66-3011a6fae714");
complaints.put("complaintNpciId", "FE4123109776644");
complaints.put("complaintRaisedFrom", "agent");
complaints.put("complaintType", "npciComplaint");
complaints.put("createdEpochDate", 1681893776);
complaints.put("creationDate", "2023-04-19T14:12:56.329935Z");
complaints.put("modifiedDate", "2023-04-19T14:13:32.25255Z");
complaints.put("modifiedEpochDate", 1681893812);
complaints.put("refId", "hHfEKYZExIpxNEV65HMQZ2Lh0DA31091413");
complaints.put("status", "COMPLAINT_CLOSURE_REQUEST_SUCCESS"); // removed spaces
complaints.put("tenantId", "FE41");
complaints.put("txnId", "155a4a71-141f-40fd-b772-9d0e020963e8");
complaints.put("txnNpciId", "FE413045Hl3L90ZWg59o");
complaints.put("userId", "FE41FE42BNK519012345");
complaints.put("agentId", "FE41FE42BNK519012345");
return finalJson;
Map<String, Object> finalJson = new HashMap<>();
finalJson.put("complaints", complaints);
return finalJson;
}
public String saveComplainStatusDetail(ViewComplainByIdResponse responseWrapper, String reqId, String txnId) {
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
// Map list → ComplaintStatusDetails list
List<ComplaintStatusDetails> entityList = responseWrapper.getComplaintsList()
.stream()
.map(c -> mapper.map(c, ComplaintStatusDetails.class))
.collect(Collectors.toList());
// Map list → ComplaintStatusDetails list
List<ComplaintStatusDetails> entityList = responseWrapper.getTickets().stream()
.map(c -> mapper.map(c, ComplaintStatusDetails.class)).collect(Collectors.toList());
// Set extra fields
for (ComplaintStatusDetails entity : entityList) {
entity.setReqId(reqId);
entity.setTxnId(txnId);
}
// Set extra fields
for (ComplaintStatusDetails entity : entityList) {
entity.setReqId(reqId);
entity.setSystemTxnId(txnId);
entity.setTotalPages(String.valueOf(responseWrapper.getTotalPages()));
entity.setTotalElements(String.valueOf(responseWrapper.getTotalElements()));
entity.setPage(String.valueOf(responseWrapper.getPage()));
entity.setPageSize(String.valueOf(responseWrapper.getPageSize()));
entity.setCreateDateTime(new Date());
// Save to repository
complainDetailRepository.saveAll(entityList);
}
return "SUCCESS";
// Save to repository
complainDetailRepository.saveAll(entityList);
return "SUCCESS";
}
// Payment Data Service Impl
public ClientReqIdResponse storeClientReqIdResponse(ClientReqIdResponse responseWrapper, String reqId,
String txnId) {
// 1. Save Parent (bill_id is PK)
CheckClientStatusReqId parent = new CheckClientStatusReqId();
parent.setBillId(responseWrapper.getBillId());
parent.setRefId(responseWrapper.getRefId());
parent.setBillerId(responseWrapper.getBillerId());
parent.setStatus(responseWrapper.getStatus());
parent.setActionType(responseWrapper.getActionType());
parent.setUserId(responseWrapper.getUserId());
parent.setCreationDate(responseWrapper.getCreationDate());
parent.setModifiedDate(responseWrapper.getModifiedDate());
parent.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
parent.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
parent.setReqId(reqId);
parent.setTxnId(txnId);
parent = clientReqIdRepository.save(parent);
// If no biller data, return
if (responseWrapper.getBillerResponse() == null) {
return responseWrapper;
}
CheckClientBillerResponseDTO dto = responseWrapper.getBillerResponse();
// 2. Save Biller Data
CheckClientBillerData billerData = new CheckClientBillerData();
billerData.setBillMaster(parent);
billerData.setAmount(dto.getAmount());
billerData.setBillDate(dto.getBillDate());
billerData.setBillNumber(dto.getBillNumber());
billerData.setBillPeriod(dto.getBillPeriod());
billerData.setCustConvFee(dto.getCustConvFee());
billerData.setCouCustConvFee(dto.getCouCustConvFee());
billerData.setDueDate(dto.getDueDate());
billerData.setCustomerName(dto.getCustomerName());
billerData.setAmountOption(dto.getAmountOption());
billerData = checkClientBillerDataRepository.save(billerData);
// 3. Save Tag List
List<BillTag> tagList = new ArrayList<>();
if (dto.getTagList() != null) {
for (Detail tagDto : dto.getTagList()) {
BillTag tag = new BillTag();
tag.setName(tagDto.getName());
tag.setValue(tagDto.getValue());
tag.setBillerResponse(billerData);
tagList.add(tag);
}
}
billerData.setTagList(tagList);
// 4. Save Additional Info
List<BillAdditionalInfo> addList = new ArrayList<>();
if (dto.getAdditionalInfo() != null) {
for (BillAdditionalInfoDTO ai : dto.getAdditionalInfo()) {
BillAdditionalInfo info = new BillAdditionalInfo();
info.setAdditionalInfoId(ai.getAdditionalInfoId());
info.setName(ai.getName());
info.setValue(ai.getValue());
info.setBillerResponse(billerData);
addList.add(info);
}
}
billerData.setAdditionalInfo(addList);
// 5. Save Customer Params
List<BillCustomerParams> cpList = new ArrayList<>();
if (dto.getCustomerParams() != null) {
for (BillCustomerParamsDTO cp : dto.getCustomerParams()) {
BillCustomerParams param = new BillCustomerParams();
param.setName(cp.getName());
param.setValue(cp.getValue());
param.setType(cp.getType());
param.setBillerResponse(billerData);
cpList.add(param);
}
}
billerData.setCustomerParams(cpList);
// Final Save for children cascade
checkClientBillerDataRepository.save(billerData);
return responseWrapper;
}
public String saveTicketDisoptionDetails(List<TicketDispositionsDTO> dispositionsList, String requestId,
String txnId) {
if (dispositionsList == null || dispositionsList.isEmpty()) {
return "No disposition data received.";
}
int savedCount = 0;
for (TicketDispositionsDTO dto : dispositionsList) {
// Check if already exists
boolean exists = ticketDispositionRepository.existsByDispositionId(dto.getDispositionId());
if (!exists) {
TicketDispositionDetails entity = new TicketDispositionDetails();
// Manual mapping (to avoid ModelMapper conflict)
entity.setDispositionId(dto.getDispositionId());
entity.setDispositionDescr(dto.getDispositionDescr());
entity.setTenantId(dto.getTenantId());
entity.setDispositionCode(dto.getDispositionCode());
// Set current datetime
entity.setCreateDateTime(new Date());
entity.setTxnId(txnId);
entity.setReqId(requestId);
ticketDispositionRepository.save(entity);
savedCount++;
}
}
if (savedCount > 0) {
return savedCount + " disposition(s) saved successfully.";
} else {
return "All dispositions already exist. No new records saved.";
}
}
public String saveAllComplaints(ViewAllComplaintsTicketsResponse responseWrapper, String reqId, String txnId) {
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
// Map list → ComplaintStatusDetails list
List<ViewAllComplaintTicketStatusDetails> entityList = responseWrapper.getTickets().stream()
.map(c -> mapper.map(c, ViewAllComplaintTicketStatusDetails.class)).collect(Collectors.toList());
// Set extra fields
for (ViewAllComplaintTicketStatusDetails entity : entityList) {
entity.setReqId(reqId);
entity.setSystemTxnId(txnId);
entity.setPage(String.valueOf(responseWrapper.getPage()));
entity.setPageSize(String.valueOf(responseWrapper.getPageSize()));
entity.setTotalPages(String.valueOf(responseWrapper.getTotalPages()));
entity.setTotalElements(String.valueOf(responseWrapper.getTotalElements()));
entity.setCreateDateTime(new Date());
}
// Save to repository
viewAllComplainTicketDetailRepository.saveAll(entityList);
return "SUCCESS";
}
}