add requestId in complaint

This commit is contained in:
Mohd-Arham
2025-12-12 15:02:05 +05:30
parent 870c37e7f5
commit 28cf0aa98d
3 changed files with 37 additions and 19 deletions
@@ -2,7 +2,6 @@ package com.billpaymentservice.bbps.entites;
import java.util.List;
import jakarta.persistence.CascadeType;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
@@ -30,6 +29,9 @@ public class ComplaintResponseEntity extends Auditable {
@Column(name = "ref_id")
private String refId;
@Column(name = "request_txn_id")
private String requestTxnId;
@Column(name = "txn_npci_id")
private String txnNpciId;
@@ -85,4 +87,3 @@ public class ComplaintResponseEntity extends Auditable {
private List<ViewAllComplaintTicketStatusDetails> viewAllList;
}
@@ -103,6 +103,7 @@ public class ComplainServiceImpl implements ComplainService {
String requestId = complainRequestDTO.getReqId();
String mid = complainRequestDTO.getMid();
String userId = complainRequestDTO.getClientUserId();
String requestTxnId=complainRequestDTO.getTxnId();
LOGGER.info("[{}] START | reqId={} | mid={} | clientUserId={}", apiName, requestId, mid, userId);
String txnId = helper.generateTxnId(15);
@@ -195,7 +196,7 @@ public class ComplainServiceImpl implements ComplainService {
ComplaintResponse responseWrapper = objectMapper.convertValue(dataMap, ComplaintResponse.class);
String saveComplaintResponseEntity = mapperHelper.saveComplaintResponseEntity(responseWrapper, requestId,
txnId, userId);
txnId, userId,requestTxnId);
LOGGER.info("Save Complaint Response Count" + saveComplaintResponseEntity);
ResponseModel responseModel = new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
@@ -720,9 +720,11 @@ public class BillerMapperHelper {
parent.setUserId(responseWrapper.getUserId());
// Map incoming DTO date strings into Auditable LocalDateTime fields
LocalDateTime parentCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
if (parentCreatedOn != null) parent.setCreatedOn(parentCreatedOn);
if (parentCreatedOn != null)
parent.setCreatedOn(parentCreatedOn);
LocalDateTime parentUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
if (parentUpdatedOn != null) parent.setUpdatedOn(parentUpdatedOn);
if (parentUpdatedOn != null)
parent.setUpdatedOn(parentUpdatedOn);
parent.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
parent.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
parent.setReqId(reqId);
@@ -978,13 +980,15 @@ public class BillerMapperHelper {
billMasterRepository.save(billMaster);
}
// Helper to parse incoming ISO date/time strings (with optional offset) into LocalDateTime
// Helper to parse incoming ISO date/time strings (with optional offset) into
// LocalDateTime
private LocalDateTime parseToLocalDateTime(String dateStr) {
if (dateStr == null || dateStr.isBlank()) {
return null;
}
try {
// Try parsing with offset first (e.g., 2023-04-19T17:28:05.508679Z or with +05:30)
// Try parsing with offset first (e.g., 2023-04-19T17:28:05.508679Z or with
// +05:30)
OffsetDateTime odt = OffsetDateTime.parse(dateStr);
return odt.toLocalDateTime();
} catch (Exception e) {
@@ -1000,7 +1004,8 @@ public class BillerMapperHelper {
// Convert TransactionMaster to master DTO
public TransactionHistoryMasterDTO toDTO(TransactionMaster transactionMaster) {
if (transactionMaster == null) return null;
if (transactionMaster == null)
return null;
TransactionHistoryMasterDTO dto = new TransactionHistoryMasterDTO();
dto.setBankTxnId(transactionMaster.getBankTxnId());
dto.setTxnId(transactionMaster.getTxnId());
@@ -1044,9 +1049,11 @@ public class BillerMapperHelper {
return dto;
}
// Convert TransactionMaster to particular details DTO (used with method references)
// Convert TransactionMaster to particular details DTO (used with method
// references)
public TransactionHistoryParticularDetailsDTO billerRemainingDetails(TransactionMaster transactionMaster) {
if (transactionMaster == null) return null;
if (transactionMaster == null)
return null;
TransactionHistoryParticularDetailsDTO dto = new TransactionHistoryParticularDetailsDTO();
dto.setBankTxnId(transactionMaster.getBankTxnId());
dto.setTxnId(transactionMaster.getTxnId());
@@ -1082,7 +1089,8 @@ public class BillerMapperHelper {
return forward;
}
// Map PaymentStartUserRequest + API response into PaymentStartRecord and persist
// Map PaymentStartUserRequest + API response into PaymentStartRecord and
// persist
public void savePaymentStartRecord(PaymentStartUserRequest request, PaymentStartApiResponse apiResponse,
String txnId, String orderNo, String requestJson, String rawResponse, String responseType) {
PaymentStartRecord record = new PaymentStartRecord();
@@ -1099,7 +1107,8 @@ public class BillerMapperHelper {
record.setQrString(Optional.ofNullable(apiResponse.getResponseData().getQrString()).orElse("NO_QR"));
// parse createdOn string into LocalDateTime and set on Auditable
LocalDateTime createdOn = parseToLocalDateTime(apiResponse.getResponseData().getCreatedOn());
if (createdOn == null) createdOn = LocalDateTime.now();
if (createdOn == null)
createdOn = LocalDateTime.now();
record.setCreatedOn(createdOn);
// default status pending
record.setTxnStatus("PENDING");
@@ -1136,9 +1145,11 @@ public class BillerMapperHelper {
return forward;
}
// Check if complaint can be raised (true if within 24 hours of transactionCreatedDateString)
// Check if complaint can be raised (true if within 24 hours of
// transactionCreatedDateString)
public static boolean isComplaintAllowed(String transactionCreatedDateString) {
if (transactionCreatedDateString == null || transactionCreatedDateString.isBlank()) return false;
if (transactionCreatedDateString == null || transactionCreatedDateString.isBlank())
return false;
try {
OffsetDateTime transactionCreatedDate = OffsetDateTime.parse(transactionCreatedDateString);
OffsetDateTime currentTime = OffsetDateTime.now();
@@ -1153,7 +1164,7 @@ public class BillerMapperHelper {
// Persist complaint response entity
public String saveComplaintResponseEntity(ComplaintResponse responseWrapper, String requestId, String txnId,
String userId) {
String userId, String requestTxnId) {
if (responseWrapper == null || responseWrapper.getTicketDetails() == null) {
return "No data";
}
@@ -1165,6 +1176,7 @@ public class BillerMapperHelper {
complaintResponseEntity.setTicketNpciId(responseWrapper.getTicketDetails().getTicketNpciId());
complaintResponseEntity.setTicketDesp(responseWrapper.getTicketDetails().getTicketDesp());
complaintResponseEntity.setTicketDesr(responseWrapper.getTicketDetails().getTicketDesr());
complaintResponseEntity.setRequestTxnId(requestTxnId);
complaintResponseEntity.setMessage(responseWrapper.getMessage());
complaintResponseEntity.setRemarks(responseWrapper.getRemarks());
@@ -1190,7 +1202,8 @@ public class BillerMapperHelper {
// Minimal mapping helpers used by AgentServiceImpl
public com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest fetchBillForwardRequestMap(
com.billpaymentservice.bbps.dto.request.FetchBillRequest req) {
if (req == null) return null;
if (req == null)
return null;
com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest f = new com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest();
f.setBillerId(req.getBillerId());
f.setBillerName(req.getBillerName());
@@ -1208,7 +1221,8 @@ public class BillerMapperHelper {
public com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(
com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest req) {
if (req == null) return null;
if (req == null)
return null;
com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest f = new com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest();
f.setBillerId(req.getBillerId());
f.setBillerName(req.getBillerName());
@@ -1222,7 +1236,8 @@ public class BillerMapperHelper {
public void saveBillValidation(com.billpaymentservice.bbps.dto.response.FetchBillValidateResponse responseWrapper,
com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest billRequest, String txnId) {
if (responseWrapper == null || billRequest == null) return;
if (responseWrapper == null || billRequest == null)
return;
BillValidation entity = new BillValidation();
entity.setBillId(responseWrapper.getBillId());
entity.setRefId(responseWrapper.getRefId());
@@ -1237,7 +1252,8 @@ public class BillerMapperHelper {
// Map additionalInfo if present (minimal mapping)
if (responseWrapper.getAdditionalInfo() != null) {
List<AdditionalInfoBillValidate> addList = new ArrayList<>();
for (com.billpaymentservice.bbps.dto.AdditionalInfoBillValidateDTO ai : responseWrapper.getAdditionalInfo()) {
for (com.billpaymentservice.bbps.dto.AdditionalInfoBillValidateDTO ai : responseWrapper
.getAdditionalInfo()) {
AdditionalInfoBillValidate info = new AdditionalInfoBillValidate();
// DTO only has name & value
info.setName(ai.getName());