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
@@ -6,7 +6,6 @@ import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -14,11 +13,10 @@ import org.springframework.web.bind.annotation.RestController;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.AllMasterOptionsRequest;
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.request.GetTicketLatestStausRequest;
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
import com.billpaymentservice.bbps.service.ComplainService;
@RestController
@@ -36,44 +34,30 @@ public class ComplainController {
this.complainService = complainService;
}
@PostMapping(value = "/addComplain", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/addComplainTicket", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> addComplain(@Validated @RequestBody ComplaintRequestDTO complainRequestDTO) {
ResponseModel response = complainService.addComplain(complainRequestDTO);
return ResponseEntity.ok(response);
}
@PostMapping(value = "/checkComplaintStatus", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> getComplaintStatus(@Validated @RequestBody ComplainStatusRequest request) {
log.info("Received complaint status request for complaintId: {}", request.getComplaintId());
@PostMapping(value = "/checkTicketStatus", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> getComplaintStatus(@Validated @RequestBody GetTicketLatestStausRequest request) {
log.info("Received complaint status request for complaintId: {}", request.getTicketId());
ResponseModel response = complainService.getComplaintStatus(request);
return ResponseEntity.ok(response);
}
@PostMapping(value = "/reOpenComplaint", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> reOpenComplaint(@Validated @RequestBody ReOpenComplain request) {
log.info("Received ReOpen Complaint request for complaintId: {}", request.getComplaintId());
ResponseModel response = complainService.reOpenComplaint(request);
return ResponseEntity.ok(response);
}
@PostMapping(value = "/viewComplainsHistory", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@PostMapping(value = "/viewComplainsTicketHistory", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> viewComplaintHistory(@Validated @RequestBody ComplainStatusRequest request) {
log.info("Received complaint View Complaint History request for complaintId: {}", request.getComplaintId());
log.info("Received complaint View Complaint History request for ticketId: {}", request.getTicketId());
ResponseModel response = complainService.viewComplaintHistory(request);
return ResponseEntity.ok(response);
}
@PostMapping(value = "/closeComplaint", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> closeComplaint(@Validated @RequestBody CloseComplaintRequest request) {
log.info("Received complaint Close Complaint request for complaintId: {}", request.getComplaintId());
ResponseModel response = complainService.closeComplaint(request);
return ResponseEntity.ok(response);
}
@PostMapping("/viewComplaintsById")
public ResponseEntity<ResponseModel> viewComplaintById(@Validated @RequestBody ViewComplainByIdRequest request) {
log.info("Received complaint View Complaint By ID request for complaintId: {}", request.getComplaintId());
@PostMapping("/viewTicketById")
public ResponseEntity<ResponseModel> viewComplaintById(@Validated @RequestBody ComplainStatusRequest request) {
log.info("Received complaint View Complaint By ID request for complaintId: {}", request.getTicketId());
ResponseModel response = complainService.viewComplaintById(request);
return ResponseEntity.ok(response);
}
@@ -82,4 +66,11 @@ public class ComplainController {
public ResponseEntity<ResponseModel> getAllStatuses(@Validated @RequestBody AllMasterOptionsRequest request) {
return ResponseEntity.ok(complainService.getAllActiveStatuses(request));
}
@PostMapping("/viewAllComplaints")
public ResponseEntity<ResponseModel> viewAllComplaints(@RequestBody ViewAllComplaintsTicketsRequest request) {
log.info("Received request complaint View All Complaints for Status Type={}", request.getStatusType());
ResponseModel response = complainService.ViewAllComplaints(request);
return ResponseEntity.ok(response);
}
}
@@ -26,7 +26,7 @@ import jakarta.validation.Valid;
@RequestMapping("/masterData")
@RestController
@Validated
@CrossOrigin(origins="*")
@CrossOrigin(origins = "*")
public class MasterDataController {
private static final Logger log = LoggerFactory.getLogger(MasterDataController.class);
@@ -39,8 +39,7 @@ public class MasterDataController {
/** Get Details of the biller by billId **/
@PostMapping(value = "/getBillerDetails", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> getBillerDetails(
@Valid @RequestBody BillerDetailRequest billerDetailRequest) {
public ResponseEntity<ResponseModel> getBillerDetails(@Valid @RequestBody BillerDetailRequest billerDetailRequest) {
log.info("Received biller details request for billerId: {}", billerDetailRequest.getBillerId());
@@ -61,6 +60,12 @@ public class MasterDataController {
return ResponseEntity.ok(masterDataService.getDispositionDetails(dispositionDetailRequest));
}
@PostMapping(value = "/getTicketDispositions", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> getTicketDispositions(
@Validated @RequestBody DispositionRequest dispositionDetailRequest) {
return ResponseEntity.ok(masterDataService.getTicketDispositions(dispositionDetailRequest));
}
/**
* Get CustomerParam by billerId.The parameter is different from the data we are
* getting in the billerDetail
@@ -74,23 +79,30 @@ public class MasterDataController {
return ResponseEntity.ok(masterDataService.getCustomerParamByBillerId(customerParamRequest));
}
/**
* Get All Master Data .The parameter is different from the data we are getting Made By Arham
* in the MasterRequest
* Get All Master Data .The parameter is different from the data we are getting
* Made By Arham in the MasterRequest
**/
@PostMapping("/getAllMastersData")
public ResponseModel fetchMasterData(@Validated @RequestBody MasterRequest masterRequest) {
return masterDataService.getMasterData(masterRequest);
}
/** POST Master CategoryResponseList Wise API Fetch CategoryResponseList Wise from BBPS URL Made By Arham **/
/**
* POST Master CategoryResponseList Wise API Fetch CategoryResponseList Wise
* from BBPS URL Made By Arham
**/
@PostMapping(value = "/getMasterCategoryWise", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> getMasterDataCategoryWise(
@Valid @RequestBody MasterCategoryRequest masterRequest) {
@Valid @RequestBody MasterCategoryRequest masterRequest) {
return ResponseEntity.ok(masterDataService.fetchMasterDataCategoryWise(masterRequest));
}
/** POST Customer Param Groups API Fetch CategoryResponseList Wise from BBPS URL Made By Arham**/
/**
* POST Customer Param Groups API Fetch CategoryResponseList Wise from BBPS URL
* Made By Arham
**/
@PostMapping(value = "/customerParamGroupsByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> getCustomerParamGroup(
@Validated @RequestBody BillerDetailRequest requestModel) {
@@ -98,8 +110,8 @@ public class MasterDataController {
}
/**
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList Wise from BBPS
* URL Made By Arham
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList
* Wise from BBPS URL Made By Arham
**/
@PostMapping(value = "/fetchAmountOptionsByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> fetchAllMasterAmountOptionsByBillerId(
@@ -108,8 +120,8 @@ public class MasterDataController {
}
/**
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList Wise from BBPS
* URL Made By Arham
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList
* Wise from BBPS URL Made By Arham
**/
@PostMapping(value = "/fetchAllPlanCategoriesByBillerId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> fetchPlanCategories(@Validated @RequestBody BillerDetailRequest requestModel) {
@@ -117,21 +129,21 @@ public class MasterDataController {
}
/**
* POST Fetch Initiating Channel API Fetch CategoryResponseList Wise from BBPS URL Made By Arham
* POST Fetch Initiating Channel API Fetch CategoryResponseList Wise from BBPS
* URL Made By Arham
**/
@PostMapping(value = "/initiatingChannel", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> initiatingChannel(@Validated @RequestBody BillerDetailRequest requestModel) {
return ResponseEntity.ok(masterDataService.fetchInitiatingChannel(requestModel));
}
/**
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList Wise from BBPS Made By Arham
* URL
* POST Fetch All AMount Options By Biller Id API Fetch CategoryResponseList
* Wise from BBPS Made By Arham URL
**/
@PostMapping(value = "/fetchPlanByCategoryName", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> fetchPlanByCategory(@Validated @RequestBody PlanRequest requestModel) {
return ResponseEntity.ok(masterDataService.fetchPlanByCategories(requestModel));
}
}
@@ -9,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.BillFetchbyClientIdRequest;
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
import com.billpaymentservice.bbps.service.PaymentService;
@@ -18,37 +19,37 @@ import com.billpaymentservice.bbps.service.PaymentService;
public class PaymentController {
/**
* Fetches bill details from external BBPS service
*/
* Fetches bill details from external BBPS service
*/
private final PaymentService paymentService;
public PaymentController(PaymentService paymentService) {
this.paymentService=paymentService;
this.paymentService = paymentService;
}
@PostMapping(
value = "/intiatePayment",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
public ResponseEntity<ResponseModel> requestBillFetch(
@Validated @RequestBody BillPaymentRequest billPaymentRequest) {
ResponseModel response = paymentService.initiatePayment(billPaymentRequest);
return ResponseEntity.ok(response);
}
@PostMapping(
value = "/checkTransactionStatus",
consumes = MediaType.APPLICATION_JSON_VALUE,
produces = MediaType.APPLICATION_JSON_VALUE
)
public ResponseEntity<ResponseModel> checkTransactionStatus(
@Validated @RequestBody TransactionStatusRequest transactionStatusRequest) {
@PostMapping(value = "/intiatePayment", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> requestBillFetch(
@Validated @RequestBody BillPaymentRequest billPaymentRequest) {
ResponseModel response = paymentService.initiatePayment(billPaymentRequest);
return ResponseEntity.ok(response);
}
@PostMapping(value = "/checkTransactionStatus", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> checkTransactionStatus(
@Validated @RequestBody TransactionStatusRequest transactionStatusRequest) {
ResponseModel response = paymentService.checkTrasactionStatus(transactionStatusRequest);
return ResponseEntity.ok(response);
}
@PostMapping(value = "/billFetchbyClientId", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> checkBillFetchbyClientId(
@Validated @RequestBody BillFetchbyClientIdRequest transactionStatusRequest) {
ResponseModel response = paymentService.checkBillFetchbyClientId(transactionStatusRequest);
return ResponseEntity.ok(response);
}
ResponseModel response = paymentService.checkTrasactionStatus(transactionStatusRequest);
return ResponseEntity.ok(response);
}
}
@@ -0,0 +1,14 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class BillAdditionalInfoDTO {
private String additionalInfoId;
private String name;
private String value;
}
@@ -0,0 +1,14 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class BillCustomerParamsDTO {
private String name;
private String value;
private String type;
}
@@ -0,0 +1,29 @@
package com.billpaymentservice.bbps.dto;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class CheckClientBillerResponseDTO {
private String billId;
private String amount;
private String billDate;
private String billNumber;
private String billPeriod;
private String custConvFee;
private String couCustConvFee;
private String dueDate;
private String customerName;
private Boolean amountOption;
private List<Detail> tagList;
// Conditional fields
private List<BillAdditionalInfoDTO> additionalInfo; // C
private List<BillCustomerParamsDTO> customerParams; // C
}
@@ -1,5 +1,7 @@
package com.billpaymentservice.bbps.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@@ -7,30 +9,33 @@ import lombok.Setter;
@Getter
public class ComplainDetailsDto {
private String complaintId;
private String complaintDescr;
private String complaintDispos;
private String complaintType;
private String txnId;
private String complaintStatus;
private String assignedTo;
private String complaintNpciId;
private String complaintRaisedFrom;
private String userId;
private String status;
private String refId;
private String estimated_TAT;
private String creationDate;
private String modifiedDate;
private String billerName;
private String txnAmount;
private String superLevelEsc;
private String openComplaint;
private String reopenComplaint;
private String remarks;
private String agentId;
private String category;
private long createdEpochDate;
private long modifiedEpochDate;
@JsonProperty("TicketId")
private String TicketId;
@JsonProperty("TicketNpciId")
private String TicketNpciId;
@JsonProperty("TxnId")
private String TxnId;
@JsonProperty("TxnNpciId")
private String TxnNpciId;
@JsonProperty("TicketStatus")
private String TicketStatus;
@JsonProperty("TicketType")
private String TicketType;
@JsonProperty("TicketDespo")
private String TicketDespo;
@JsonProperty("TicketDescr")
private String TicketDescr;
@JsonProperty("TicketRaisedBy")
private String TicketRaisedBy;
@JsonProperty("CreatedTime")
private String CreatedTime;
@JsonProperty("TxnAmount")
private String TxnAmount;
@JsonProperty("TotalTxnAmount")
private String TotalTxnAmount;
@JsonProperty("BillCategory")
private String BillCategory;
@JsonProperty("BillerName")
private String BillerName;
}
@@ -9,24 +9,12 @@ import lombok.Setter;
@Getter
@Setter
@JsonIgnoreProperties(ignoreUnknown = true)
public class ComplaintDetailsDTO {
private String complaintId; // UUID
private String complaintDescr; // Complaint description
private String complaintDispos; // Complaint disposition
private String complaintType;
// Complaint type
@JsonProperty("txnId")
private String bankTxnId; // Transaction ID
private String txnNpciId; // Transaction NPCI ID
private String assignedTo; // Assigned person
private String complaintNpciId; // Complaint NPCI ID
private String complaintRaisedFrom; // Who raised the complaint
private String userId; // User ID
private String status; // Complaint status
private String refId; // Reference ID
private String estimated_TAT; // Estimated Turnaround Time
private String creationDate; // ISO timestamp
private String modifiedDate; // ISO timestamp
private Long createdEpochDate; // Epoch creation time
private Long modifiedEpochDate; // Epoch modified time
public class ComplaintDetailsDTO {
private String refId; // UUID
private String txnNpciId; // Complaint description
private String ticketId; // Complaint disposition
private String ticketType;
private String ticketNpciId; // Transaction ID
private String ticketDesp; // Transaction NPCI ID
private String ticketDesr; // Assigned person
}
@@ -7,19 +7,9 @@ import lombok.Setter;
@Setter
public class ComplaintHistoryDTO {
private String complaintHistoryId;
private String complaintId;
private String complaintDescr;
private String complaintDispos;
private String txnId;
private String assignedTo;
private String complaintNpciId;
private String complaintType;
private String complaintRaisedFrom;
private String userId;
private String status;
private String modifiedDate; // ISO 8601 Timestamp
private Long modifiedEpochDate; // UNIX Epoch
private String tenantId;
private String historyId;
private String ticketId;
private String time;
private String historyStatus;
}
@@ -0,0 +1,21 @@
package com.billpaymentservice.bbps.dto;
import lombok.Data;
@Data
public class TicketDetailsDTO {
private String ticketId;
private String ticketNpciId;
private String txnNpciId;
private String ticketType;
private String ticketDespo;
private String ticketDescr;
private String status;
private String npciTicketType;
private String npciTicketStatus;
private String createdTime;
}
@@ -0,0 +1,15 @@
package com.billpaymentservice.bbps.dto;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TicketDispositionsDTO {
private String dispositionId;
private String dispositionDescr;
private String tenantId;
private String dispositionCode;
}
@@ -2,7 +2,6 @@ package com.billpaymentservice.bbps.dto;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@@ -10,34 +9,46 @@ import lombok.Setter;
@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;
@JsonProperty("TicketId")
private String ticketId;
@JsonProperty("TicketNpciId")
private String ticketNpciId;
@JsonProperty("TxnId")
private String txnId;
@JsonProperty("TxnNpciId")
private String txnNpciId;
@JsonProperty("TicketStatus")
private String ticketStatus;
@JsonProperty("TicketType")
private String ticketType;
@JsonProperty("TicketDespo")
private String ticketDespo;
@JsonProperty("TicketDescr")
private String ticketDescr;
@JsonProperty("TicketRaisedBy")
private String ticketRaisedBy;
@JsonProperty("CreatedTime")
private String creationDate;
private String estimated_TAT;
private String modifiedDate;
private String modifiedEpochDate;
private String refId;
private String status;
@JsonProperty("txnId")
private String bankTxnId;
private String userId;
private String category;
private String billerName;
@JsonProperty("TxnAmount")
private String txnAmount;
private String totalTxnAmount;
private String complaintStatus;
private String superLevelEsc;
private String openComplaint;
private String reopenComplaint;
private String remarks;
private String agentId;
@JsonProperty("TotalTxnAmount")
private String totalTxnAmount;
@JsonProperty("BillCategory")
private String billCategory;
@JsonProperty("BillerName")
private String billerName;
}
@@ -6,8 +6,9 @@ import lombok.Setter;
@Getter
@Setter
public class ViewComplainByIdRequest extends BaseClass {
public class BillFetchbyClientIdRequest extends BaseClass{
@NotBlank(message = "client Req Id is not be null")
private String clientReqId;
@NotBlank(message = "Complain ID cannot be blank")
private String complaintId;
}
@@ -13,6 +13,6 @@ import lombok.Setter;
@NoArgsConstructor
public class ComplainStatusRequest extends BaseClass {
@NotBlank(message = "Complaint Id cannot be null or blank")
private String complaintId;
@NotBlank(message = "ticketId Id cannot be null or blank")
private String ticketId;
}
@@ -7,9 +7,11 @@ import lombok.Setter;
@Setter
public class ComplaintRequestDTO extends BaseClass {
private String complaintDescription; // Complaint description that the user enters
private String complaintDisposition; // Complaint disposition
private String complaintType; // Type of complaint
private String txnId; // Transaction ID (optional)
private String clientReqId; // Client Req ID (optional)
private String ticketDescription; // Complaint description that the user enters
private String ticketDisposition; // Complaint disposition
private String ticketDispositionCode; // Type of complaint
private String txnId; // Transaction ID (optional)
private String billerId; // Client Req ID (optional);
private String billerName;
}
@@ -0,0 +1,25 @@
package com.billpaymentservice.bbps.dto.request;
import com.fasterxml.jackson.annotation.JsonIgnore;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class GetTicketLatestStausRequest extends BaseClass {
@NotBlank(message = "txnNpciId Id cannot be null or blank")
private String txnNpciId;
@NotBlank(message = "ticketId Id cannot be null or blank")
private String ticketId;
private String tenantId;
}
@@ -0,0 +1,15 @@
package com.billpaymentservice.bbps.dto.request;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ViewAllComplaintsTicketsRequest extends BaseClass{
private String statusType; // e.g. COMPLAINT_OPEN_SUCCESS
private Integer pageNo; // default 0
private Integer pageSize; // default 10
private String ticketType; // default 10
}
@@ -24,6 +24,6 @@ public class AmountOptionsResponse {
@JsonProperty("amountOptionDAOS")
private List<AmountOptionDTO> amountOptionDAOS;
@JsonProperty("generalResp")
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
}
@@ -0,0 +1,28 @@
package com.billpaymentservice.bbps.dto.response;
import com.billpaymentservice.bbps.dto.CheckClientBillerResponseDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ClientReqIdResponse {
private String billId;
private String refId;
private String billerId;
private String status;
private String actionType;
private String userId;
private String creationDate;
private String modifiedDate;
private Long createdEpochDate;
private Long modifiedEpochDate;
private CheckClientBillerResponseDTO billerResponse;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp genericResponse;
}
@@ -17,12 +17,8 @@ import lombok.Setter;
@AllArgsConstructor
public class ComplaintHistoryStatusResponse {
private List<ComplaintHistoryDTO> complaintsHistories;
private List<ComplaintHistoryDTO> ticketHistories;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
private int pageNo;
private int pageSize;
private int totalPages;
private int totalElements;
}
@@ -1,8 +1,6 @@
package com.billpaymentservice.bbps.dto.response;
import com.billpaymentservice.bbps.dto.ComplaintDetailsDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@@ -10,7 +8,10 @@ import lombok.Setter;
@Getter
@Setter
public class ComplaintResponse {
private ComplaintDetailsDTO complaints; // multiple complaints
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
private ComplaintDetailsDTO ticketDetails; // multiple complaints
private String message;
private String remarks;
private String status;
private String statusCode;
}
@@ -0,0 +1,17 @@
package com.billpaymentservice.bbps.dto.response;
import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
import lombok.Data;
@Data
public class TicketCheckStatusResponse {
private String refId;
private TicketDetailsDTO ticketDetails;
private String message;
private String remarks;
private String status;
private String statusCode;
}
@@ -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.TicketDispositionsDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class TicketDispositionResponse {
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
List<TicketDispositionsDTO> dispositionsList;
}
@@ -0,0 +1,24 @@
package com.billpaymentservice.bbps.dto.response;
import java.util.List;
import com.billpaymentservice.bbps.dto.ComplainDetailsDto;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ViewAllComplaintsTicketsResponse {
private List<ComplainDetailsDto> tickets;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
private Integer page;
private Integer pageSize;
private Integer totalPages;
private Long totalElements;
}
@@ -4,6 +4,7 @@ import java.util.List;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.ViewComplaintDTO;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Getter;
import lombok.Setter;
@@ -11,10 +12,11 @@ import lombok.Setter;
@Getter
@Setter
public class ViewComplainByIdResponse {
private List<ViewComplaintDTO> complaintsList;
private GeneralResp generalResp;
private int pageNo;
private int pageSize;
private int totalPages;
private int totalElements;
private List<ViewComplaintDTO> tickets;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private GeneralResp generalResp;
private int page;
private int pageSize;
private int totalPages;
private int totalElements;
}
@@ -0,0 +1,31 @@
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "bill_additional_info")
public class BillAdditionalInfo {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String value;
private String additionalInfoId;
@ManyToOne
@JoinColumn(name = "biller_response_id")
private CheckClientBillerData billerResponse;
}
@@ -0,0 +1,31 @@
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "bill_customer_params")
public class BillCustomerParams {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String value;
private String type;
@ManyToOne
@JoinColumn(name = "biller_response_id")
private CheckClientBillerData billerResponse;
}
@@ -0,0 +1,30 @@
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.ManyToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
@Entity
@Table(name = "bill_tag_list")
public class BillTag {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
private String name;
private String value;
@ManyToOne
@JoinColumn(name = "biller_response_id")
private CheckClientBillerData billerResponse;
}
@@ -0,0 +1,68 @@
package com.billpaymentservice.bbps.entites;
import java.util.List;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn;
import jakarta.persistence.OneToMany;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "check_client_biller_data")
@Getter
@Setter
public class CheckClientBillerData {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
// Correct 1-1 link back to Parent
@OneToOne
@JoinColumn(name = "bill_id", referencedColumnName = "bill_id")
private CheckClientStatusReqId billMaster;
@Column(name = "amount")
private String amount;
@Column(name = "bill_date")
private String billDate;
@Column(name = "bill_number")
private String billNumber;
@Column(name = "bill_period")
private String billPeriod;
@Column(name = "cust_conv_fee")
private String custConvFee;
@Column(name = "cou_cust_conv_fee")
private String couCustConvFee;
@Column(name = "due_date")
private String dueDate;
@Column(name = "customer_name")
private String customerName;
@Column(name = "amount_option")
private Boolean amountOption;
@OneToMany(mappedBy = "billerResponse", cascade = CascadeType.ALL)
private List<BillTag> tagList;
@OneToMany(mappedBy = "billerResponse", cascade = CascadeType.ALL)
private List<BillAdditionalInfo> additionalInfo;
@OneToMany(mappedBy = "billerResponse", cascade = CascadeType.ALL)
private List<BillCustomerParams> customerParams;
}
@@ -0,0 +1,60 @@
package com.billpaymentservice.bbps.entites;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Id;
import jakarta.persistence.OneToOne;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Entity
@Table(name = "check_client_status_req_id")
@Getter
@Setter
public class CheckClientStatusReqId {
@Id
@Column(name = "bill_id", length = 200)
private String billId; // Primary Key (UUID from BBPS)
@Column(name = "ref_id")
private String refId;
@Column(name = "biller_id")
private String billerId;
@Column(name = "status")
private String status;
@Column(name = "action_type")
private String actionType;
@Column(name = "user_id")
private String userId;
@Column(name = "creation_date")
private String creationDate;
@Column(name = "modified_date")
private String modifiedDate;
@Column(name = "created_epoch_date")
private Long createdEpochDate;
@Column(name = "modified_epoch_date")
private Long modifiedEpochDate;
@Column(name = "req_id")
private String reqId;
@Column(name = "txn_id")
private String txnId;
// Correct OneToOne Child Mapping
@OneToOne(mappedBy = "billMaster", cascade = CascadeType.ALL)
private CheckClientBillerData billerResponse;
}
@@ -19,88 +19,53 @@ public class ComplainStatus extends Auditable<String> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "complaint_id")
private String complaintId;
@Column(name = "complaint_descr")
private String complaintDescr;
@Column(name = "complaint_dispos")
private String complaintDispos;
@Column(name = "complaint_type")
private String complaintType;
@Column(name = "txn_id")
private String txnId;
@Column(name = "complaint_status")
private String complaintStatus;
@Column(name = "assigned_to")
private String assignedTo;
@Column(name = "complaint_npci_id")
private String complaintNpciId;
@Column(name = "complaint_raised_from")
private String complaintRaisedFrom;
@Column(name = "user_id")
private String userId;
@Column(name = "status")
private String status;
@Column(name = "ref_id")
private String refId;
@Column(name = "estimated_tat")
private String estimatedTAT;
@Column(name = "ticket_id")
private String ticketId;
@Column(name = "creation_date")
private String creationDate;
@Column(name = "ticket_npci_id")
private String ticketNpciId;
@Column(name = "modified_date")
private String modifiedDate;
@Column(name = "txn_npci_id")
private String txnNpciId;
@Column(name = "biller_name")
private String billerName;
@Column(name = "ticket_type")
private String ticketType;
@Column(name = "txn_amount")
private String txnAmount;
@Column(name = "ticket_despo", columnDefinition = "TEXT")
private String ticketDespo;
@Column(name = "super_level_esc")
private String superLevelEsc;
@Column(name = "ticket_descr", columnDefinition = "TEXT")
private String ticketDescr;
@Column(name = "open_complaint")
private String openComplaint;
@Column(name = "status")
private String status;
@Column(name = "reopen_complaint")
private String reopenComplaint;
@Column(name = "npci_ticket_type")
private String npciTicketType;
@Column(name = "npci_ticket_status")
private String npciTicketStatus;
@Column(name = "created_time")
private String createdTime;
@Column(name = "remarks")
private String remarks;
@Column(name = "agent_id")
private String agentId;
@Column(name = "message")
private String message;
@Column(name = "category")
private String category;
@Column(name = "created_epoch_date")
private long createdEpochDate;
@Column(name = "modified_epoch_date")
private long modifiedEpochDate;
@Column(name = "response_status")
private String statusCode;
@Column(name = "req_id")
private String reqId;
@Column(name = "system_txn_id")
private String systemTxnId;
@Column(name = "txn_id")
private String txnId;
}
@@ -25,63 +25,21 @@ public class ComplaintHistory extends Auditable<String> {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "complaint_id")
private String complaintId;
@Column(name = "complaint_descr")
private String complaintDescr;
@Column(name = "complaint_dispos")
private String complaintDispos;
@Column(name="history_id")
private String historyId;
@Column(name="ticket_id")
private String ticketId;
@Column(name="time")
private String time;
@Column(name="history_status")
private String historyStatus;
@Column(name = "txn_id")
private String txnId;
@Column(name = "complaint_history_id")
private String complaintHistoryId;
@Column(name = "assigned_to")
private String assignedTo;
@Column(name = "complaint_npci_id")
private String complaintNpciId;
@Column(name = "complaint_raised_from")
private String complaintRaisedFrom;
@Column(name = "user_id")
private String userId;
@Column(name = "status")
private String status;
@Column(name = "ref_id")
private String refId;
@Column(name = "complaint_type")
private String complaintType; // internalComplaint or npciComplaint
@Column(name = "modified_date")
private String modifiedDate; // ISO 8601 timestamp
@Column(name = "modified_epoch_date")
private Long modifiedEpochDate; // UNIX epoch timestamp
@Column(name = "page_no")
private int pageNo;
@Column(name = "page_size")
private int pageSize;
@Column(name = "total_pages")
private int totalPages;
@Column(name = "total_elements")
private int totalElements;
@Column(name = "system_txn_id")
private String systemTxnId;
@Column(name = "req_id")
private String reqId;
@@ -1,6 +1,11 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
@@ -9,95 +14,74 @@ import lombok.Setter;
@Entity
@Getter
@Setter
@Table(name = "complaint_status_details")
public class ComplaintStatusDetails {
@Table(name = "view_ticket_status")
public class ComplaintStatusDetails extends Auditable<String>{
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "req_id")
private String reqId;
@Id
@Column(name = "req_id")
private String reqId;
@Column(name = "txn_id")
private String txnId;
private String complaintId;
@Column(name = "txn_id")
private String systemTxnId;
@Column(name = "assigned_to")
private String assignedTo;
@Column(name = "total_elements")
private String totalElements;
@Column(name = "comment")
private String comment;
@Column(name = "page")
private String page;
@Column(name = "complaint_descr")
private String complaintDescr;
@Column(name = "page_size")
private String pageSize;
@Column(name = "complaint_dispos")
private String complaintDispos;
@Column(name = "total_pages")
private String totalPages;
@Column(name = "complaint_npci_id")
private String complaintNpciId;
@Column(name = "complaint_dispos")
private String complaintDispos;
@Column(name = "complaint_raised_from")
private String complaintRaisedFrom;
@Column(name = "ticket_id")
private String ticketId;
@Column(name = "complaint_type")
private String complaintType;
@Column(name = "ticket_npci_id")
private String ticketNpciId;
@Column(name = "created_epoch_date")
private String createdEpochDate;
@Column(name = "bank_txn_id")
private String txnId;
@Column(name = "creation_date")
private String creationDate;
@Column(name = "txn_npci_id")
private String txnNpciId;
@Column(name = "estimated_tat")
private String estimated_TAT;
@Column(name = "ticket_status")
private String ticketStatus;
@Column(name = "modified_date")
private String modifiedDate;
@Column(name = "ticket_type")
private String ticketType;
@Column(name = "modified_epoch_date")
private String modifiedEpochDate;
@Column(name = "ticket_despo")
private String ticketDespo;
@Column(name = "ref_id")
private String refId;
@Column(name = "ticket_descr")
private String ticketDescr;
@Column(name = "status")
private String status;
@Column(name = "ticket_raised_by")
private String ticketRaisedBy;
@Column(name = "bank_txn_id")
private String bank_txnId;
@Column(name = "created_time")
private String createdTime;
@Column(name = "user_id")
private String userId;
@Column(name = "txn_amount")
private String txnAmount;
@Column(name = "category")
private String category;
@Column(name = "total_txn_amount")
private String totalTxnAmount;
@Column(name = "biller_name")
private String billerName;
@Column(name = "bill_category")
private String billCategory;
@Column(name = "txn_amount")
private String txnAmount;
@Column(name = "total_txn_amount")
private String totalTxnAmount;
@Column(name = "complaint_status")
private String complaintStatus;
@Column(name = "super_level_esc")
private String superLevelEsc;
@Column(name = "open_complaint")
private String openComplaint;
@Column(name = "reopen_complaint")
private String reopenComplaint;
@Column(name = "remarks")
private String remarks;
@Column(name = "agent_id")
private String agentId;
}
@Column(name = "biller_name")
private String billerName;
}
@@ -0,0 +1,44 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@Entity
@Table(name = "ticket_disposition_details")
@ToString
public class TicketDispositionDetails extends Auditable<String> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "disposition_id", nullable = false)
private String dispositionId; // UUID type string
@Column(name = "disposition_descr", nullable = false)
private String dispositionDescr;
@Column(name = "tenant_id")
private String tenantId;
@Column(name = "disposition_code")
private String dispositionCode;
@Column(name = "req_id")
private String reqId;
@Column(name = "txn_id")
private String txnId;
}
@@ -0,0 +1,86 @@
package com.billpaymentservice.bbps.entites;
import com.billpaymentservice.bbps.audit.Auditable;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import lombok.Getter;
import lombok.Setter;
@Entity
@Getter
@Setter
@Table(name = "view_all_complaint_ticket_status")
public class ViewAllComplaintTicketStatusDetails extends Auditable<String> {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "req_id")
private String reqId;
@Column(name = "txn_id")
private String systemTxnId;
@Column(name = "total_elements")
private String totalElements;
@Column(name = "page")
private String page;
@Column(name = "page_size")
private String pageSize;
@Column(name = "total_pages")
private String totalPages;
@Column(name = "complaint_dispos")
private String complaintDispos;
@Column(name = "ticket_id")
private String ticketId;
@Column(name = "ticket_npci_id")
private String ticketNpciId;
@Column(name = "bank_txn_id")
private String txnId;
@Column(name = "txn_npci_id")
private String txnNpciId;
@Column(name = "ticket_status")
private String ticketStatus;
@Column(name = "ticket_type")
private String ticketType;
@Column(name = "ticket_despo")
private String ticketDespo;
@Column(name = "ticket_descr")
private String ticketDescr;
@Column(name = "ticket_raised_by")
private String ticketRaisedBy;
@Column(name = "created_time")
private String createdTime;
@Column(name = "txn_amount")
private String txnAmount;
@Column(name = "total_txn_amount")
private String totalTxnAmount;
@Column(name = "bill_category")
private String billCategory;
@Column(name = "biller_name")
private String billerName;
}
@@ -0,0 +1,11 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.BillAdditionalInfo;
@Repository
public interface BillAdditionalInfoRepository extends JpaRepository<BillAdditionalInfo,Long>{
}
@@ -0,0 +1,11 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.BillCustomerParams;
@Repository
public interface BillCustomerParamsRepository extends JpaRepository<BillCustomerParams, Long> {
}
@@ -0,0 +1,11 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.BillTag;
@Repository
public interface BillTagRepository extends JpaRepository<BillTag, Long> {
}
@@ -0,0 +1,11 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.CheckClientBillerData;
@Repository
public interface CheckClientBillerDataRepository extends JpaRepository<CheckClientBillerData,Long>{
}
@@ -0,0 +1,11 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.CheckClientStatusReqId;
@Repository
public interface ClientReqIdRepository extends JpaRepository<CheckClientStatusReqId, String> {
}
@@ -6,6 +6,6 @@ import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.ComplaintStatusDetails;
@Repository
public interface ComplainDetailRepository extends JpaRepository<ComplaintStatusDetails,String> {
public interface ComplainDetailRepository extends JpaRepository<ComplaintStatusDetails,Long> {
}
@@ -8,4 +8,5 @@ import com.billpaymentservice.bbps.entites.ComplainStatus;
@Repository
public interface ComplaintStatusRepository extends JpaRepository<ComplainStatus, Long> {
boolean existsByTicketId(String ticketId);
}
@@ -0,0 +1,12 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.TicketDispositionDetails;
@Repository
public interface TicketDispositionRepository extends JpaRepository<TicketDispositionDetails, Long> {
boolean existsByDispositionId(String dispositionId);
}
@@ -0,0 +1,11 @@
package com.billpaymentservice.bbps.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import com.billpaymentservice.bbps.entites.ViewAllComplaintTicketStatusDetails;
@Repository
public interface ViewAllComplainTicketDetailRepository extends JpaRepository<ViewAllComplaintTicketStatusDetails,Long> {
}
@@ -2,29 +2,26 @@ package com.billpaymentservice.bbps.service;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.AllMasterOptionsRequest;
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.TxnStatusRequest;
import com.billpaymentservice.bbps.dto.request.ViewComplainByIdRequest;
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
public interface ComplainService {
ResponseModel getComplaintStatus(ComplainStatusRequest request);
ResponseModel reOpenComplaint(ReOpenComplain request);
ResponseModel getComplaintStatus(GetTicketLatestStausRequest request);
ResponseModel viewComplaintHistory(ComplainStatusRequest request);
ResponseModel closeComplaint(CloseComplaintRequest request);
ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO);
ResponseModel viewComplaintById(ViewComplainByIdRequest request);
ResponseModel viewComplaintById(ComplainStatusRequest request);
ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request);
ResponseModel checkTxnStatus(TxnStatusRequest request);
ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request);
}
@@ -33,4 +33,6 @@ public interface MasterDataService {
public ResponseModel fetchPlanByCategories(PlanRequest requestModel);
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest);
}
@@ -1,6 +1,7 @@
package com.billpaymentservice.bbps.service;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.BillFetchbyClientIdRequest;
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
@@ -10,4 +11,6 @@ public interface PaymentService {
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest);
public ResponseModel checkBillFetchbyClientId(BillFetchbyClientIdRequest transactionStatusRequest);
}
@@ -222,7 +222,7 @@ public class AgentServiceImpl implements AgentService {
String txnId = helper.generateTxnId(15);
String reqId = billFetchByBillIdRequest.getReqId();
String billId = billFetchByBillIdRequest.getBillId();
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "1ced7566-1add-4e01-9ed6-04cd67ac9684";
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + "43f61299-7682-4586-b298-1f8828dcaa46";
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
@@ -3,8 +3,6 @@ package com.billpaymentservice.bbps.serviceImpl;
import java.util.List;
import java.util.Map;
import org.modelmapper.ModelMapper;
import org.modelmapper.convention.MatchingStrategies;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
@@ -16,20 +14,18 @@ import org.springframework.web.client.RestClient;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.AllMasterOptionsRequest;
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.GetTicketLatestStausRequest;
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
import com.billpaymentservice.bbps.dto.request.ViewComplainByIdRequest;
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
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.TicketCheckStatusResponse;
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
import com.billpaymentservice.bbps.entites.ComplaintDetails;
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
import com.billpaymentservice.bbps.entites.InboundTraceLog;
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
@@ -45,6 +41,7 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
@Service
public class ComplainServiceImpl implements ComplainService {
@@ -82,14 +79,20 @@ public class ComplainServiceImpl implements ComplainService {
@Override
public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO) {
LOGGER.info("Initiating addComplain for request ID: {} and MID", complainRequestDTO.getReqId(),
LOGGER.info("Initiating add Complain for request ID: {} and MID {}", complainRequestDTO.getReqId(),
complainRequestDTO.getMid());
String apiName = "ADDCOMPLAIN";
String apiName = "ADD_COMPLAIN";
String txnId = helper.generateTxnId(15);
String requestId = complainRequestDTO.getReqId();
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
// Convert input DTO to JSON
String requestJson = helper.convertObjectToJson(complainRequestDTO);
// Fetch tenant & agent from DB
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
HttpHeaders headers = new HttpHeaders();
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
headers.set("agentId", headersData.getAgentId());
@@ -98,233 +101,155 @@ public class ComplainServiceImpl implements ComplainService {
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, complainRequestDTO.getMid(),
"POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST", null);
LOGGER.info("Calling external API: {}", fullUrl);
LOGGER.info("Request payload: {}", requestJson);
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
String responseData = responseMap.get("data");
LOGGER.info("fetched data from api is :{}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
// Inject tenantId + agentId into request JSON
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
root.put("tenantId", headersData.getTenantId());
root.put("agentId", headersData.getAgentId());
String finalJson = root.toString();
LOGGER.info("Final Request Sent to API: {}", finalJson);
// IMPORTANT: Send finalJson, not requestJson
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
String responseData = responseMap.get("data");
LOGGER.info("Fetched response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
// Handle HttpService error wrapper
if (responseData.startsWith("HttpService Error")) {
int start = responseData.indexOf("{");
int end = responseData.lastIndexOf("}");
if (start != -1 && end != -1) {
responseData = responseData.substring(start, end + 1);
}
LOGGER.info("Extracted pure JSON from error: {}", responseData);
}
// Parse JSON into Map
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
LOGGER.info("Parsed response data: {}", dataMap);
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
// Throw exception for non-200
if (statusCode != 200) {
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")));
statusCode, String.valueOf(dataMap.get("remarks")));
}
// Convert to response wrapper
ComplaintResponse responseWrapper = objectMapper.convertValue(dataMap, ComplaintResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
ComplaintDetails entity = mapper.map(responseWrapper.getComplaints(), ComplaintDetails.class);
entity.setReqId(complainRequestDTO.getReqId());
entity.setTxnId(txnId);
complainRepository.save(entity);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
ResponseModel responseModel = new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
LOGGER.error("JSON Parsing Error: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
@Override
public ResponseModel getComplaintStatus(ComplainStatusRequest request) {
LOGGER.info("Fetching Compalint Status by Complaint Id={}", request.getComplaintId(), request.getReqId());
// String apiName = "Complaint Status";
// String txnId = helper.generateTxnId(15);
// String reqId = request.getReqId();
// String complaintId = request.getComplaintId();
// String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
//
// 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(), "POST",
// requestJson);
// OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
// LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
public ResponseModel getComplaintStatus(GetTicketLatestStausRequest request) {
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
String apiName = "COMPLAINT_STATUS";
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String complaintId = request.getTicketId();
String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
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);
// Convert request to JSON
String requestJson = helper.convertObjectToJson(request);
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
try {
//
// LOGGER.info("Calling external API: {}", fullUrl);
// Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
// String responseData = responseMap.get("data");
// LOGGER.info("Complaint FetchById Response: {}", responseData);
//
//
//
// // Dummy complaint map start
// JsonNode root = objectMapper.readTree(responseData);
// String message = root.path("message").asText("");
// String statuss = root.path("status").asText("");
//
// // dummy data send when server response is coming error.
// // Check for internal server error
// if ("Internal server error, please try again later".equalsIgnoreCase(message)) {
//
// Map<String, Object> dummyComplaint = mapperHelper.getComplaintStatusJson();
//
// LOGGER.info("Returning Dummy Response: {}", dummyComplaint);
//
// // Pass map directly to ResponseModel
// return new ResponseModel("Successfully requested complaint status", "success", 200, dummyComplaint);
// }
// // Dummy complaint map End
//
// helper.updateOutboundLogResponse(outboundLog, responseData);
//
// Map<String, Object> dataMap = objectMapper.readValue(responseData,
// new TypeReference<Map<String, Object>>() {
// });
//
// if (!dataMap.containsKey("genericResponse")) {
// 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(dataMap.get("remarks")));
// }
//
// ComplaintStatusResponse responseWrapper = objectMapper.convertValue(dataMap, ComplaintStatusResponse.class);
// GeneralResp generalResp = responseWrapper.getGeneralResp();
//
// String status = generalResp.getStatus();
// LOGGER.info("Current Complaint Status: {}", status);
//
// helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
// mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
// LOGGER.info("Complaint data saved successfully for billId: {}", complaintId);
//
// 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");
Map<String, Object> dummyComplaint = mapperHelper.getComplaintStatusJson();
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
LOGGER.info("Returning Dummy Response: {}", dummyComplaint);
String responseData = responseMap.get("data");
// Pass map directly to ResponseModel
return new ResponseModel("Successfully requested complaint status", "success", 200, dummyComplaint);
LOGGER.info("Complaint Fetch Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
// Dummy complaint map End
if (responseData.startsWith("HttpService Error")) {
int start = responseData.indexOf("{");
int end = responseData.lastIndexOf("}");
if (start != -1 && end != -1) {
responseData = responseData.substring(start, end + 1);
LOGGER.info("Extracted Clean JSON: {}", responseData);
}
}
} catch (Exception ex) {
LOGGER.error("Error parsing response JSON", ex);
throw new CustomException("Error " + ex.getMessage());
}
}
// Convert JSON to Map
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
@Override
public ResponseModel reOpenComplaint(ReOpenComplain request) {
LOGGER.info("Fetching ReOpen Complaint by Complaint Id={}", request.getComplaintId(), request.getReqId());
// String apiName = "Complaint Status";
// String txnId = helper.generateTxnId(15);
// String reqId = request.getReqId();
// String complaintId = request.getComplaintId();
// String fullUrl = agentDtaUrl + BBPSConstant.REOPEN_COMPALINT;
//
// 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(), "POST",
// requestJson);
// OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
// LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
try {
// LOGGER.info("Calling external API: {}", fullUrl);
// Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
// String responseData = responseMap.get("data");
// LOGGER.info("Complaint ReOpen FetchById Response: {}", responseData);
if (statusCode != 200) {
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
statusCode, String.valueOf(dataMap.get("remarks")));
}
// Dummy complaint map start
// Check for internal server error
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
TicketCheckStatusResponse.class);
Map<String, Object> dummyComplaint = mapperHelper.getDummyReopenComplaintJson();
LOGGER.info("Returning Dummy Response: {}", dummyComplaint);
LOGGER.info("Complaint Current Status: {}", responseWrapper.getStatus());
return new ResponseModel("Complaint reopening requested", "success", 200, dummyComplaint);
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
// Dummy complaint map End
// Save in DB
mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
return new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing Complaint Status JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
// helper.updateOutboundLogResponse(outboundLog, responseData);
//
// Map<String, Object> dataMap = objectMapper.readValue(responseData,
// new TypeReference<Map<String, Object>>() {
// });
//
// 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(dataMap.get("remarks")));
// }
//
// ComplaintStatusResponse responseWrapper = objectMapper.convertValue(dataMap, ComplaintStatusResponse.class);
// GeneralResp generalResp = responseWrapper.getGeneralResp();
//
// String status = generalResp.getStatus();
// LOGGER.info("Current Complaint ReOpen Status: {}", status);
//
// helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
// mapperHelper.saveReOpenComplaint(responseWrapper, reqId, txnId);
// LOGGER.info("Complaint ReOpen data saved successfully for billId: {}", complaintId);
//
// 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");
} catch (Exception ex) {
LOGGER.error("Error parsing response JSON", ex);
throw new CustomException("Error " + ex.getMessage());
}
}
@Override
public ResponseModel viewComplaintHistory(ComplainStatusRequest request) {
LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getComplaintId(),
LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getTicketId(),
request.getReqId());
String apiName = "Complaint Status";
String apiName = "View_Complaint_History";
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String complaintId = request.getComplaintId();
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getComplaintId();
String ticketId = request.getTicketId();
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId();
helper.validateMerchant(request.getMid());
@@ -341,7 +266,7 @@ public class ComplainServiceImpl implements ComplainService {
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", complaintId);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
@@ -384,92 +309,14 @@ public class ComplainServiceImpl implements ComplainService {
}
@Override
public ResponseModel closeComplaint(CloseComplaintRequest request) {
LOGGER.info("Fetching Close Complaint by Complaint Id={}", request.getComplaintId(), request.getReqId());
// String apiName = "Complaint Status";
// String txnId = helper.generateTxnId(15);
// String reqId = request.getReqId();
// String complaintId = request.getComplaintId();
// String fullUrl = agentDtaUrl + BBPSConstant.CLOSE_COMPLAINT;
//
// 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(), "POST",
// requestJson);
// OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
// LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
public ResponseModel viewComplaintById(ComplainStatusRequest request) {
try {
// LOGGER.info("Calling external API: {}", fullUrl);
// Map<String, String> responseMap = httpService.postRequest(fullUrl, requestJson, headers);
// String responseData = responseMap.get("data");
// LOGGER.info("Complaint Close FetchById Response: {}", responseData);
// Dummy complaint map Start
Map<String, Object> dummyComplaint = mapperHelper.getDummyClosureComplaintJson();
LOGGER.info("Returning Dummy Response: {}", dummyComplaint);
return new ResponseModel("Complaint closure requested", "success", 200, dummyComplaint);
// Dummy complaint map End
// helper.updateOutboundLogResponse(outboundLog, responseData);
//
// Map<String, Object> dataMap = objectMapper.readValue(responseData,
// new TypeReference<Map<String, Object>>() {
// });
//
// if (!dataMap.containsKey("genericResponse")) {
// 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(dataMap.get("remarks")));
// }
//
// CloseComplaintStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
// CloseComplaintStatusResponse.class);
// GeneralResp generalResp = responseWrapper.getGeneralResp();
//
// String status = generalResp.getStatus();
// LOGGER.info("Current Complaint Close Status: {}", status);
//
// helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
// // mapperHelper.saveReOpenComplaint(responseWrapper, reqId, txnId);
// LOGGER.info("Complaint Close data saved successfully for billId: {}", complaintId);
//
// 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");
} catch (Exception e) {
throw new CustomException("Invalid JSON received from API" + e.getMessage());
}
}
@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";
LOGGER.info("Fetching View Complaint Complaint by Complaint Id={}", request.getTicketId(), 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();
String ticketId = request.getTicketId();
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
helper.validateMerchant(request.getMid());
@@ -486,7 +333,7 @@ public class ComplainServiceImpl implements ComplainService {
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", complaintId);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
@@ -516,14 +363,8 @@ public class ComplainServiceImpl implements ComplainService {
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);
String saveComplaint = mapperHelper.saveComplainStatusDetail(responseWrapper, reqId, txnId);
// LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}",
// saveComplaintHistory);
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
@@ -538,7 +379,6 @@ public class ComplainServiceImpl implements ComplainService {
public ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request) {
try {
LOGGER.info("Fetch All Master Options - MID: {}", request.getMid());
String apiName = "View All Options Fetch By Id";
String txnId = helper.generateTxnId(15);
@@ -580,7 +420,7 @@ public class ComplainServiceImpl implements ComplainService {
}
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
LOGGER.info("Fetching TxnStatusRequest by Id={} and ReqId ={}", request.getId(), request.getReqId());
LOGGER.info("Check Txn Status Request by Id={} and ReqId ={}", request.getId(), request.getReqId());
String apiName = "CheckTxnStatus";
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
@@ -631,11 +471,6 @@ public class ComplainServiceImpl implements ComplainService {
LOGGER.info("Current Complaint ReOpen Status: {}", status);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
// String saveComplaint = mapperHelper.saveComplainStatusDetail(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) {
@@ -646,4 +481,74 @@ public class ComplainServiceImpl implements ComplainService {
}
@Override
public ResponseModel ViewAllComplaints(ViewAllComplaintsTicketsRequest request) {
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
request.getReqId());
String apiName = "View_All_Complaint_By_Status_Type";
String txnId = helper.generateTxnId(15);
String reqId = request.getReqId();
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
+ request.getTicketType();
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(), "POST",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET",
request.getStatusType());
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
try {
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
LOGGER.info("Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
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(""));
}
ViewAllComplaintsTicketsResponse responseWrapper = objectMapper.convertValue(dataMap,
ViewAllComplaintsTicketsResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
String status = generalResp.getStatus();
LOGGER.info("Current Complaint ReOpen Status: {}", status);
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}",
saveComplaint);
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");
}
}
}
@@ -1,6 +1,7 @@
// java
package com.billpaymentservice.bbps.serviceImpl;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@@ -12,10 +13,8 @@ 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.CustomerParamGroupsDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.MasterApiResponse;
import com.billpaymentservice.bbps.dto.ResponseModel;
@@ -35,6 +34,7 @@ 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.dto.response.TicketDispositionResponse;
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
import com.billpaymentservice.bbps.entites.BillerCategoryWise;
import com.billpaymentservice.bbps.entites.BillerDetails;
@@ -42,6 +42,7 @@ import com.billpaymentservice.bbps.entites.CustomParam;
import com.billpaymentservice.bbps.entites.DispositionDetails;
import com.billpaymentservice.bbps.entites.InboundTraceLog;
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
import com.billpaymentservice.bbps.entites.TicketDispositionDetails;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
import com.billpaymentservice.bbps.repository.BillerDataRepository;
@@ -50,6 +51,7 @@ import com.billpaymentservice.bbps.repository.DispositionRepository;
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.MerchantRepository;
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.TicketDispositionRepository;
import com.billpaymentservice.bbps.service.MasterDataService;
import com.billpaymentservice.bbps.util.BBPSConstant;
import com.billpaymentservice.bbps.util.BillerMapperHelper;
@@ -71,6 +73,7 @@ public class MasterDataServiceImpl implements MasterDataService {
private MerchantRepository merchantRegisterRepo;
private HttpClientApi httpClientApi;
private final DispositionRepository dispositionRepository;
private final Helper helper;
private final BillerDataRepository billerDataRespository;
private final HttpService httpService;
@@ -95,6 +98,7 @@ public class MasterDataServiceImpl implements MasterDataService {
this.outboundTraceLogRepository = outboundTraceLogRepository;
this.mapperHelper = mapperHelper;
this.customParamReposiotory = customParamReposiotory;
}
@@ -123,7 +127,7 @@ public class MasterDataServiceImpl implements MasterDataService {
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
//LOGGER.info("Response Data: {}", responseData);
// LOGGER.info("Response Data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
@@ -192,7 +196,7 @@ public class MasterDataServiceImpl implements MasterDataService {
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
EntityRelationshipUtil.linkBillerRelationships(entity);// linking nesting entity foreign key
//helper.saveOrUpdateBillerData(entity);
// helper.saveOrUpdateBillerData(entity);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
@@ -292,7 +296,7 @@ public class MasterDataServiceImpl implements MasterDataService {
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
//LOGGER.info("Response Data: {}", responseData);
// LOGGER.info("Response Data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -671,4 +675,58 @@ public class MasterDataServiceImpl implements MasterDataService {
}
}
@Override
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest) {
LOGGER.info("Fetching Ticket Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetTicketDispositionDetails";
String requestId = dispositionDetailRequest.getReqId();
helper.validateMerchant(dispositionDetailRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
dispositionDetailRequest.getMid(), "GET", "N/A");
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
ObjectMapper objectMapper = new ObjectMapper();
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
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")));
}
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
TicketDispositionResponse.class);
System.out.println(responseWrapper);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
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");
}
}
}
@@ -10,11 +10,14 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import com.billpaymentservice.bbps.dto.GeneralResp;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.BillFetchbyClientIdRequest;
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
import com.billpaymentservice.bbps.dto.request.TransactionStatusRequest;
import com.billpaymentservice.bbps.dto.response.BillPaymentResponse;
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
import com.billpaymentservice.bbps.dto.response.TransactionStatusResponse;
import com.billpaymentservice.bbps.entites.AgentFundTransfer;
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
@@ -33,6 +36,7 @@ import com.billpaymentservice.bbps.repository.PaymentRepository;
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
import com.billpaymentservice.bbps.service.PaymentService;
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.annotation.JsonInclude;
@@ -55,6 +59,7 @@ public class PaymentServiceImpl implements PaymentService {
private final PaymentIntiateRepository paymentIntiateRepository;
private final TransactionMasterRepository transactionMasterRepository;
private final AgentFundTransferRepository agentFundTransferRepository;
private final BillerMapperHelper mapperHelper;
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
@@ -62,7 +67,7 @@ public class PaymentServiceImpl implements PaymentService {
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
TransactionMasterRepository transactionMasterRepository,
AgentFundTransferRepository agentFundTransferRepository) {
AgentFundTransferRepository agentFundTransferRepository, BillerMapperHelper mapperHelper) {
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
this.httpService = httpService;
this.helper = helper;
@@ -72,163 +77,167 @@ public class PaymentServiceImpl implements PaymentService {
this.paymentIntiateRepository = paymentIntiateRepository;
this.transactionMasterRepository = transactionMasterRepository;
this.agentFundTransferRepository = agentFundTransferRepository;
this.mapperHelper = mapperHelper;
}
@Override
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
String apiName = "InitiatePayment";
String txnId = helper.generateTxnId(15);
String requestId = billPaymentRequest.getReqId();
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
String apiName = "InitiatePayment";
String txnId = helper.generateTxnId(15);
String requestId = billPaymentRequest.getReqId();
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
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);
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);
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
String requestJson = helper.convertObjectToJson(billPaymentRequest);
String requestJson = helper.convertObjectToJson(billPaymentRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), "POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST", requestJson);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(),
"POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST", requestJson);
try {
LOGGER.info("Calling BBPS payment URL: {}", url);
Map<String, String> responseMap = httpService.postRequest(url, requestJson, headers);
String responseData = responseMap.get("data");
LOGGER.info("Payment API Response: {}", responseData);
try {
LOGGER.info("Calling BBPS payment URL: {}", url);
Map<String, String> responseMap = httpService.postRequest(url, requestJson, headers);
String responseData = responseMap.get("data");
LOGGER.info("Payment API Response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
if (responseData == null || responseData.isEmpty()) {
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
throw new CustomException("Empty response from BBPS server");
}
if (responseData == null || responseData.isEmpty()) {
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
throw new CustomException("Empty response from BBPS server");
}
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
if (!dataMap.containsKey("genericResponse")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
throw new CustomException("Invalid response structure from BBPS");
}
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("genericResponse")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
throw new CustomException("Invalid response structure from BBPS");
}
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
paymentRepository.save(entity);
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
paymentRepository.save(entity);
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
PaymentInitiate paymentInitiate = new PaymentInitiate();
paymentInitiate.setTxnId(txnId);
paymentInitiate.setReqId(requestId);
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
paymentInitiate.setStatus(billPaymentResponse.getStatus());
paymentIntiateRepository.save(paymentInitiate);
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
PaymentInitiate paymentInitiate = new PaymentInitiate();
paymentInitiate.setTxnId(txnId);
paymentInitiate.setReqId(requestId);
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
paymentInitiate.setStatus(billPaymentResponse.getStatus());
paymentIntiateRepository.save(paymentInitiate);
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
transactionStatusRequest.setReqId(requestId);
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
}
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
transactionStatusRequest.setReqId(requestId);
} catch (JsonProcessingException e) {
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
try {
Thread.sleep(2000);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
}
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
} catch (JsonProcessingException e) {
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
String apiName = "CheckTransactionStatus";
String txnId = helper.generateTxnId(15);
String requestId = transactionStatusRequest.getReqId();
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
InboundTraceLog inboundLog) {
String apiName = "CheckTransactionStatus";
String txnId = helper.generateTxnId(15);
String requestId = transactionStatusRequest.getReqId();
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
transactionStatusRequest.getTxnId(), requestId);
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);
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();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
ObjectMapper objectMapper = new ObjectMapper();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get("data");
LOGGER.info("Transaction status response: {}", responseData);
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get("data");
LOGGER.info("Transaction status response: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
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"))
);
}
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
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")));
}
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class);
transactionMaster.setTxnId(txnId);
transactionMaster.setReqId(transactionStatusRequest.getReqId());
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
transactionMasterRepository.save(transactionMaster);
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(),
TransactionMaster.class);
transactionMaster.setTxnId(txnId);
transactionMaster.setReqId(transactionStatusRequest.getReqId());
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
transactionMasterRepository.save(transactionMaster);
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
agentFundTransfer.setTxnId(txnId);
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
agentFundTransferRepository.save(agentFundTransfer);
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(),
AgentFundTransfer.class);
agentFundTransfer.setTxnId(txnId);
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
agentFundTransferRepository.save(agentFundTransfer);
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", 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 transaction status JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
@Override
@@ -238,182 +247,250 @@ public class PaymentServiceImpl implements PaymentService {
String apiName = "checkTrasactionStatus";
String requestId = transactionStatusRequest.getReqId();
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
transactionStatusRequest.getTxnId(), requestId);
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);
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);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
ObjectMapper objectMapper = new ObjectMapper();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
transactionStatusRequest.getMid(), "POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
ObjectMapper objectMapper = new ObjectMapper();
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get("data");
LOGGER.info("Transaction status response data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get("data");
LOGGER.info("Transaction status response data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", transactionStatusRequest.getTxnId());
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"))
);
}
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
transactionStatusRequest.getTxnId());
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")));
}
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
String status = generalResp.getStatus();
LOGGER.info("Current transaction status: {}", status);
String status = generalResp.getStatus();
LOGGER.info("Current transaction status: {}", status);
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(), e);
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(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
@Override
public ResponseModel checkBillFetchbyClientId(BillFetchbyClientIdRequest transactionStatusRequest) {
helper.validateMerchant(transactionStatusRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "checkTrasactionStatus";
String requestId = transactionStatusRequest.getReqId();
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_URL
+ transactionStatusRequest.getClientReqId();
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
transactionStatusRequest.getClientReqId(), requestId);
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);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
transactionStatusRequest.getMid(), "POST", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
ObjectMapper objectMapper = new ObjectMapper();
//String saveDummyToDatabase = mapperHelper.saveDummyToDatabase();
//LOGGER.info("Return Status"+ saveDummyToDatabase);
Map<String, String> responseMap = httpService.getRequest(url, headers);
String responseData = responseMap.get("data");
LOGGER.info("Transaction status response data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
transactionStatusRequest.getClientReqId());
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")));
}
ClientReqIdResponse responseWrapper = objectMapper.convertValue(dataMap, ClientReqIdResponse.class);
GeneralResp generalResp = responseWrapper.getGenericResponse();
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
mapperHelper.storeClientReqIdResponse(responseWrapper,requestId,txnID);
String status = generalResp.getStatus();
LOGGER.info("Current transaction status: {}", status);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
throw new CustomException("Invalid JSON received from API");
}
}
}
/* PollBack logic for the fetchTxnByTxnId API
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
* billFetchByBillIdRequest) {
*
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
* System.out.print(fullUrl);
*
* BeneficiaryDetails
* 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);
*
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
* String responseData = responseMap.get("data"); log.info("data is :{}",
* responseData);
*
*
* ObjectMapper objectMapper = new ObjectMapper();
*
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
* TypeReference<Map<String, Object>>() { }); if
* (!dataMap.containsKey("genericResponse")) { 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")) ); }
*
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
* BillDataResponse.class);
*
* GeneralResp generalResp = responseWrapper.getGenericResponse();
*
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
* responseWrapper);
*
* return responseModel;
*
* } catch (JsonProcessingException e) {
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
* new CustomException("Invalid JSON received from API"); }
*
* }
*/
/*
* PollBack logic for the fetchTxnByTxnId API
*
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
* billFetchByBillIdRequest) {
*
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
* System.out.print(fullUrl);
*
* BeneficiaryDetails
* 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);
*
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
* String responseData = responseMap.get("data"); log.info("data is :{}",
* responseData);
*
*
* ObjectMapper objectMapper = new ObjectMapper();
*
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
* TypeReference<Map<String, Object>>() { }); if
* (!dataMap.containsKey("genericResponse")) { 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")) ); }
*
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
* BillDataResponse.class);
*
* GeneralResp generalResp = responseWrapper.getGenericResponse();
*
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
* responseWrapper);
*
* return responseModel;
*
* } catch (JsonProcessingException e) {
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
* new CustomException("Invalid JSON received from API"); }
*
* }
*/
/*
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
* transactionStatusRequest.getTxnId(); ;
*
* 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();
*
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
* apiName, url, "GET", null);
*
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
* intervalMs = 5000;
*
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
* headers); String responseData = responseMap.get("data");
* LOGGER.info("Transaction status response: {}", responseData);
*
* helper.updateOutboundLogResponse(outboundLog, responseData);
*
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
* TypeReference<Map<String, Object>>() {});
*
* if (!dataMap.containsKey("generalResp")) {
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
* 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")) ); }
*
* TransactionStatusResponse responseWrapper =
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
* GeneralResp generalResp = responseWrapper.getGeneralResp();
*
* String status = generalResp.getStatus();
* LOGGER.info("Current transaction status: {}", status);
*
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
* "Timeout after 40 seconds", "FAILED"); throw new
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
* "Transaction still in progress"); }
*
* Thread.sleep(intervalMs); continue; }
*
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
* responseWrapper );
*
* helper.updateInboundLogSuccess(inboundLog, responseData,
* generalResp.getStatus()); return responseModel;
*
* } catch (JsonProcessingException e) {
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
* throw new CustomException("Invalid JSON received from API"); } catch
* (InterruptedException e) { Thread.currentThread().interrupt();
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
* throw new CustomException("Thread interrupted during transaction check"); } }
* }
*
*
*/
/*
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
* transactionStatusRequest.getTxnId(); ;
*
* 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();
*
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
* apiName, url, "GET", null);
*
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
* intervalMs = 5000;
*
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
* headers); String responseData = responseMap.get("data");
* LOGGER.info("Transaction status response: {}", responseData);
*
* helper.updateOutboundLogResponse(outboundLog, responseData);
*
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
* TypeReference<Map<String, Object>>() {});
*
* if (!dataMap.containsKey("generalResp")) {
* helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
* 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")) ); }
*
* TransactionStatusResponse responseWrapper =
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
* GeneralResp generalResp = responseWrapper.getGeneralResp();
*
* String status = generalResp.getStatus();
* LOGGER.info("Current transaction status: {}", status);
*
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
* "Timeout after 40 seconds", "FAILED"); throw new
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
* "Transaction still in progress"); }
*
* Thread.sleep(intervalMs); continue; }
*
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
* responseWrapper );
*
* helper.updateInboundLogSuccess(inboundLog, responseData,
* generalResp.getStatus()); return responseModel;
*
* } catch (JsonProcessingException e) {
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
* throw new CustomException("Invalid JSON received from API"); } catch
* (InterruptedException e) { Thread.currentThread().interrupt();
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
* throw new CustomException("Thread interrupted during transaction check"); } }
* }
*
*
*/
@@ -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";
}
}
@@ -20,9 +20,9 @@ swagger.server.description=Local Development Server
# DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
spring.datasource.username=postgres
#spring.datasource.password=UAT@DB_2025
spring.datasource.password=UAT@DB_2025
spring.datasource.password=himanshu@123
#spring.datasource.password=himanshu@123
spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource