|
|
|
@@ -720,6 +720,7 @@ public class BillerMapperHelper {
|
|
|
|
|
parent.setUserId(responseWrapper.getUserId());
|
|
|
|
|
// Map incoming DTO date strings into Auditable LocalDateTime fields
|
|
|
|
|
LocalDateTime parentCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
|
|
|
|
|
|
|
|
|
|
LocalDateTime parentUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
|
|
|
|
|
parent.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
|
|
|
|
parent.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
|
|
|
|
@@ -963,7 +964,7 @@ public class BillerMapperHelper {
|
|
|
|
|
// DATES
|
|
|
|
|
// Map incoming DTO date strings into Auditable LocalDateTime fields
|
|
|
|
|
LocalDateTime bmCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
LocalDateTime bmUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
|
|
|
|
|
if (bmUpdatedOn != null) {
|
|
|
|
|
billMaster.setUpdatedDateTime(bmUpdatedOn);
|
|
|
|
@@ -974,13 +975,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) {
|
|
|
|
@@ -996,7 +999,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());
|
|
|
|
@@ -1040,9 +1044,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());
|
|
|
|
@@ -1078,7 +1084,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();
|
|
|
|
@@ -1095,7 +1102,7 @@ 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());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
record.setTxnStatus("PENDING");
|
|
|
|
|
} else {
|
|
|
|
|
record.setAmount("0.00");
|
|
|
|
@@ -1129,9 +1136,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();
|
|
|
|
@@ -1146,7 +1155,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";
|
|
|
|
|
}
|
|
|
|
@@ -1158,6 +1167,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());
|
|
|
|
@@ -1183,7 +1193,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());
|
|
|
|
@@ -1201,7 +1212,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());
|
|
|
|
@@ -1215,7 +1227,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());
|
|
|
|
@@ -1230,7 +1243,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());
|
|
|
|
|