diff --git a/src/main/java/com/billpaymentservice/bbps/controller/ComplainController.java b/src/main/java/com/billpaymentservice/bbps/controller/ComplainController.java index cf3dcf4..9a6b7de 100644 --- a/src/main/java/com/billpaymentservice/bbps/controller/ComplainController.java +++ b/src/main/java/com/billpaymentservice/bbps/controller/ComplainController.java @@ -19,6 +19,7 @@ import com.billpaymentservice.bbps.dto.request.CloseComplaintRequest; import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest; import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO; import com.billpaymentservice.bbps.dto.request.ReOpenComplain; +import com.billpaymentservice.bbps.dto.request.ViewComplainByIdRequest; import com.billpaymentservice.bbps.service.ComplainService; @RestController @@ -70,5 +71,11 @@ public class ComplainController { ResponseModel response = complainService.closeComplaint(request); return ResponseEntity.ok(response); } - + + @PostMapping("/viewComplaintsById") + public ResponseEntity viewComplaintById(@RequestBody ViewComplainByIdRequest request) { + log.info("Received complaint View Complaint By ID request for complaintId: {}", request.getComplaintId()); + ResponseModel response = complainService.viewComplaintById(request); + return ResponseEntity.ok(response); + } } diff --git a/src/main/java/com/billpaymentservice/bbps/dto/CustomerParamDAO.java b/src/main/java/com/billpaymentservice/bbps/dto/CustomerParamDAO.java index 4d96f6b..999ae0b 100644 --- a/src/main/java/com/billpaymentservice/bbps/dto/CustomerParamDAO.java +++ b/src/main/java/com/billpaymentservice/bbps/dto/CustomerParamDAO.java @@ -1,13 +1,25 @@ package com.billpaymentservice.bbps.dto; -import jakarta.validation.constraints.NotBlank; +import com.fasterxml.jackson.annotation.JsonInclude; + +import lombok.AllArgsConstructor; import lombok.Getter; +import lombok.NoArgsConstructor; import lombok.Setter; @Getter @Setter +@AllArgsConstructor +@NoArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) public class CustomerParamDAO { - private String paramsId; + public CustomerParamDAO(String name, String value, String type) { + + this.name = name; + this.value = value; + this.type = type; + } + private String paramsId; private String name; private String value; private String type; diff --git a/src/main/java/com/billpaymentservice/bbps/dto/ViewComplaintDTO.java b/src/main/java/com/billpaymentservice/bbps/dto/ViewComplaintDTO.java new file mode 100644 index 0000000..df28213 --- /dev/null +++ b/src/main/java/com/billpaymentservice/bbps/dto/ViewComplaintDTO.java @@ -0,0 +1,40 @@ +package com.billpaymentservice.bbps.dto; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@JsonIgnoreProperties(ignoreUnknown = true) +public class ViewComplaintDTO { + private String assignedTo; + private String comment; + private String complaintDescr; + private String complaintDispos; + private String complaintId; + private String complaintNpciId; + private String complaintRaisedFrom; + private String complaintType; + private String createdEpochDate; + private String creationDate; + private String estimated_TAT; + private String modifiedDate; + private String modifiedEpochDate; + private String refId; + private String status; + private String txnId; + private String userId; + private String category; + private String billerName; + private String txnAmount; + private String totalTxnAmount; + private String complaintStatus; + private String superLevelEsc; + private String openComplaint; + private String reopenComplaint; + private String remarks; + private String agentId; + +} diff --git a/src/main/java/com/billpaymentservice/bbps/dto/request/ViewComplainByIdRequest.java b/src/main/java/com/billpaymentservice/bbps/dto/request/ViewComplainByIdRequest.java new file mode 100644 index 0000000..f8f8f95 --- /dev/null +++ b/src/main/java/com/billpaymentservice/bbps/dto/request/ViewComplainByIdRequest.java @@ -0,0 +1,13 @@ +package com.billpaymentservice.bbps.dto.request; + +import jakarta.validation.constraints.NotBlank; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ViewComplainByIdRequest extends BaseClass { + + @NotBlank(message = "Complain ID cannot be blank") + private String complaintId; +} diff --git a/src/main/java/com/billpaymentservice/bbps/dto/response/ViewComplainByIdResponse.java b/src/main/java/com/billpaymentservice/bbps/dto/response/ViewComplainByIdResponse.java new file mode 100644 index 0000000..c04a820 --- /dev/null +++ b/src/main/java/com/billpaymentservice/bbps/dto/response/ViewComplainByIdResponse.java @@ -0,0 +1,20 @@ +package com.billpaymentservice.bbps.dto.response; + +import java.util.List; + +import com.billpaymentservice.bbps.dto.GeneralResp; +import com.billpaymentservice.bbps.dto.ViewComplaintDTO; + +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +public class ViewComplainByIdResponse { + private List complaintsList; + private GeneralResp generalResp; + private int pageNo; + private int pageSize; + private int totalPages; + private int totalElements; +} diff --git a/src/main/java/com/billpaymentservice/bbps/service/ComplainService.java b/src/main/java/com/billpaymentservice/bbps/service/ComplainService.java index cd0323f..cd87eaa 100644 --- a/src/main/java/com/billpaymentservice/bbps/service/ComplainService.java +++ b/src/main/java/com/billpaymentservice/bbps/service/ComplainService.java @@ -4,6 +4,7 @@ import com.billpaymentservice.bbps.dto.ResponseModel; import com.billpaymentservice.bbps.dto.request.CloseComplaintRequest; import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest; import com.billpaymentservice.bbps.dto.request.ReOpenComplain; +import com.billpaymentservice.bbps.dto.request.ViewComplainByIdRequest; import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO; public interface ComplainService { @@ -18,4 +19,6 @@ public interface ComplainService { public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO); + ResponseModel viewComplaintById(ViewComplainByIdRequest request); + } diff --git a/src/main/java/com/billpaymentservice/bbps/serviceImpl/ComplainServiceImpl.java b/src/main/java/com/billpaymentservice/bbps/serviceImpl/ComplainServiceImpl.java index 891a534..d95f664 100644 --- a/src/main/java/com/billpaymentservice/bbps/serviceImpl/ComplainServiceImpl.java +++ b/src/main/java/com/billpaymentservice/bbps/serviceImpl/ComplainServiceImpl.java @@ -20,10 +20,12 @@ import com.billpaymentservice.bbps.dto.request.CloseComplaintRequest; import com.billpaymentservice.bbps.dto.request.ComplainStatusRequest; import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO; import com.billpaymentservice.bbps.dto.request.ReOpenComplain; +import com.billpaymentservice.bbps.dto.request.ViewComplainByIdRequest; import com.billpaymentservice.bbps.dto.response.CloseComplaintStatusResponse; import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse; import com.billpaymentservice.bbps.dto.response.ComplaintResponse; import com.billpaymentservice.bbps.dto.response.ComplaintStatusResponse; +import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse; import com.billpaymentservice.bbps.entites.BharatConnectMaster; import com.billpaymentservice.bbps.entites.ComplaintDetails; import com.billpaymentservice.bbps.entites.InboundTraceLog; @@ -455,4 +457,72 @@ public class ComplainServiceImpl implements ComplainService { } } + @Override + public ResponseModel viewComplaintById( ViewComplainByIdRequest request) { + + LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getComplaintId(), + request.getReqId()); + String apiName = "View Complaint By ID"; + String txnId = helper.generateTxnId(15); + String reqId = request.getReqId(); + String complaintId = request.getComplaintId(); + String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getComplaintId(); + + helper.validateMerchant(request.getMid()); + + BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001"); + HttpHeaders headers = new HttpHeaders(); + headers.set("x-digiledge-key", headersData.getXDigiledgeKey()); + headers.set("agentId", headersData.getAgentId()); + headers.set("tenantId", headersData.getTenantId()); + headers.setContentType(MediaType.APPLICATION_JSON); + + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + String requestJson = helper.convertObjectToJson(request); + + InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET", + requestJson); + OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", complaintId); + LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl); + + try { + LOGGER.info("Calling external API: {}", fullUrl); + Map responseMap = httpService.getRequest(fullUrl, headers); + String responseData = responseMap.get("data"); + LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData); + + helper.updateOutboundLogResponse(outboundLog, responseData); + + Map dataMap = objectMapper.readValue(responseData, + new TypeReference>() { + }); + + if (!dataMap.containsKey("generalResp")) { + helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE"); + LOGGER.warn("Invalid response structure for txnId: {}", txnId); + throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")), + Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf("")); + } + + ViewComplainByIdResponse responseWrapper = objectMapper.convertValue(dataMap, + ViewComplainByIdResponse.class); + GeneralResp generalResp = responseWrapper.getGeneralResp(); + + String status = generalResp.getStatus(); + LOGGER.info("Current Complaint ReOpen Status: {}", status); + + helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); + //String saveComplaintHistory = mapperHelper.saveComplaintHistory(responseWrapper, reqId, txnId); + //LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaintHistory); + + return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), + Integer.parseInt(generalResp.getStatusCode()), responseWrapper); + } catch (JsonProcessingException e) { + LOGGER.error("Error parsing Complaint Id JSON: {}", e.getMessage(), e); + helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR"); + throw new CustomException("Invalid JSON received from API"); + } + } + } diff --git a/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java b/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java index b01ba77..13a825d 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java +++ b/src/main/java/com/billpaymentservice/bbps/util/BBPSConstant.java @@ -46,6 +46,7 @@ public class BBPSConstant { public static final String REOPEN_COMPALINT = "/couapp/complaints/reopen"; public static final String COMPLAINT_HISTORY = "/couapp/complaints/history/byId?complaintId="; 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 PLANS_URL = "/plans"; public static final String ADD_COMPLAIN_ENDPOINT = "/couapp/complaints"; diff --git a/src/main/java/com/billpaymentservice/bbps/util/Helper.java b/src/main/java/com/billpaymentservice/bbps/util/Helper.java index dc5815b..624b31c 100644 --- a/src/main/java/com/billpaymentservice/bbps/util/Helper.java +++ b/src/main/java/com/billpaymentservice/bbps/util/Helper.java @@ -245,70 +245,123 @@ public class Helper { } public void saveOrUpdateBillerData(BillDataResponse responseWrapper, - BillFetchByBillIdRequest billFetchByBillIdRequest) { - BillMaster billMaster =new BillMaster(); - billMaster.setBillId("12333333hjsdfjsfdj"); - billMaster.setRefId(responseWrapper.getRefId()); - billMaster.setBillerId(responseWrapper.getBillerId()); - billMaster.setStatus(responseWrapper.getStatus()); - billMaster.setActionType(responseWrapper.getActionType()); - billMaster.setUserId(responseWrapper.getUserId()); - billMaster.setReqId(billFetchByBillIdRequest.getReqId()); // if available from your API request - billMaster.setTxnId("jhnjhbhj"); // give it from method + BillFetchByBillIdRequest billFetchByBillIdRequest) { - // ---- BILLER RESPONSE ---- - BillerResponse billerResponse = new BillerResponse(); - if (responseWrapper.getBillerResponse() != null) { - billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId()); - billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount()); - billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate()); - billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber()); - billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod()); - billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee()); - billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee()); - billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate()); - billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName()); - billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption()); - billerResponse.setBillMaster(billMaster); // maintain mapping - } - billMaster.setBillerResponse(billerResponse); - // ---- ADDITIONAL INFO ---- - List additionalInfos = new ArrayList<>(); - if (responseWrapper.getAdditionalInfo() != null) { - for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) { - AdditionalInfoBill entity = new AdditionalInfoBill(); - entity.setName(info.getName()); - entity.setValue(info.getValue()); - entity.setBillMaster(billMaster); // maintain mapping - additionalInfos.add(entity); - - } - } - billMaster.setAdditionalInfo(additionalInfos); +// ------------------------------------------------------------ +// 🔥 1. STATIC ADDITIONAL INFO LIST (overwrite before mapping) +// ------------------------------------------------------------ +List staticAdditional = new ArrayList<>(); - // ---- CUSTOMER PARAMS ---- - List customerParams = new ArrayList<>(); - if (responseWrapper.getCustomerParams() != null) { - for (CustomerParamDAO param : responseWrapper.getCustomerParams()) { - CustomerParamBill entity = new CustomerParamBill(); - entity.setName(param.getName()); - entity.setValue(param.getValue()); - entity.setType(param.getType()); - entity.setBillMaster(billMaster); - customerParams.add(entity); - } - } - billMaster.setCustomerParams(customerParams); +staticAdditional.add(new AdditionalInfoBillDTO("123", "Student Name", "AGAMJOT TEST ")); +staticAdditional.add(new AdditionalInfoBillDTO("333", "Father Name", "VIRENDER SINGH")); +staticAdditional.add(new AdditionalInfoBillDTO("908", "Class", "STD I")); +staticAdditional.add(new AdditionalInfoBillDTO("097", "Section", "A")); +staticAdditional.add(new AdditionalInfoBillDTO("321", "TUITION FEE", "8670")); +staticAdditional.add(new AdditionalInfoBillDTO("121", "E-CARE FEE", "900")); +staticAdditional.add(new AdditionalInfoBillDTO("111", "COMPUTER FEE", "1350")); +staticAdditional.add(new AdditionalInfoBillDTO("121", "EXAM FEE", "500")); - // ---- DATES ---- - billMaster.setCreationDate(responseWrapper.getCreationDate()); - billMaster.setModifiedDate(responseWrapper.getModifiedDate()); - billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate()); - billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate()); - - billMasterRepository.save(billMaster); +// Static set (overwrite) +responseWrapper.setAdditionalInfo(staticAdditional); + + + +// ------------------------------------------------------------ +// 🔥 2. STATIC CUSTOMER PARAMS LIST (overwrite before mapping) +// ------------------------------------------------------------ +List staticCustomerParams = new ArrayList<>(); + +staticCustomerParams.add(new CustomerParamDAO( +"Admission No/Application No/GR No", "LF3130", "test" +)); + +staticCustomerParams.add(new CustomerParamDAO( +"Date Of Birth (DD-MM-YYYY)", "10/08/2000", "test" +)); + +staticCustomerParams.add(new CustomerParamDAO( +"Mobile No", "9241842248", "test" +)); + +// Static set (overwrite) +responseWrapper.setCustomerParams(staticCustomerParams); + +// ------------------------------------------------------------ +// 🔥 REST OF YOUR ORIGINAL LOGIC — NO CHANGE +// ------------------------------------------------------------ + +BillMaster billMaster = new BillMaster(); + +billMaster.setBillId("12333333hjsdfjsfdj"); +billMaster.setRefId(responseWrapper.getRefId()); +billMaster.setBillerId(responseWrapper.getBillerId()); +billMaster.setStatus(responseWrapper.getStatus()); +billMaster.setActionType(responseWrapper.getActionType()); +billMaster.setUserId(responseWrapper.getUserId()); +billMaster.setReqId(billFetchByBillIdRequest.getReqId()); +billMaster.setTxnId("jhnjhbhj"); + + +// BILLER RESPONSE +BillerResponse billerResponse = new BillerResponse(); +if (responseWrapper.getBillerResponse() != null) { +billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId()); +billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount()); +billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate()); +billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber()); +billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod()); +billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee()); +billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee()); +billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate()); +billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName()); +billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption()); +billerResponse.setBillMaster(billMaster); +} +billMaster.setBillerResponse(billerResponse); + + + +// ADDITIONAL INFO +List additionalInfos = new ArrayList<>(); +if (responseWrapper.getAdditionalInfo() != null) { +for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) { +AdditionalInfoBill entity = new AdditionalInfoBill(); +entity.setName(info.getName()); +entity.setValue(info.getValue()); +entity.setBillMaster(billMaster); +additionalInfos.add(entity); +} +} +billMaster.setAdditionalInfo(additionalInfos); + + + +// CUSTOMER PARAMS +List customerParams = new ArrayList<>(); +if (responseWrapper.getCustomerParams() != null) { +for (CustomerParamDAO param : responseWrapper.getCustomerParams()) { +CustomerParamBill entity = new CustomerParamBill(); +entity.setName(param.getName()); +entity.setValue(param.getValue() == null ? "" : param.getValue()); +entity.setType(param.getType() == null ? "" : param.getType()); +entity.setBillMaster(billMaster); +customerParams.add(entity); +} +} +billMaster.setCustomerParams(customerParams); + + + +// DATES +billMaster.setCreationDate(responseWrapper.getCreationDate()); +billMaster.setModifiedDate(responseWrapper.getModifiedDate()); +billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate()); +billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate()); + + +billMasterRepository.save(billMaster); +} - } public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) { System.out.println("responseWrapper"); ModelMapper modelMapper = new ModelMapper();