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