half commited
This commit is contained in:
@@ -51,8 +51,8 @@ public class BBPSConstant extends BBPS_RESPONSE_COD_CONSTANT {
|
||||
public static final String BILL_FETCH_BY_ID = "/couapp/bills/fetch/byId?billId=";
|
||||
public static final String BILL_FETCH_BY_CLIENT_REQ_ID = "/couapp/bills/fetch/byClientId?clientReqId=";
|
||||
public static final String BILL_VALIDATE_BY_CLIENT_REQ_ID = "/couapp/bills/validate/byClientId?clientReqId=";
|
||||
public static final String PAYMENT_URL = "/agent/bills/payment";
|
||||
public static final String CHECK_TRANSACTION_URL = "/transactions/payment/byTxnId?txnId=";
|
||||
public static final String PAYMENT_URL = "/agent/bills/paymhent";
|
||||
public static final String CHECK_TRANSACTION_URL = "/transactions/payment/byTxnId?txnId=j";
|
||||
|
||||
public static final String CHECK_TRANSACTION_BY_CLIENT_URL = "/bills/fetch/byClientId?clientReqId=";
|
||||
public static final String CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL = "/transactions/payment/byClientId?clientReqId=";
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.billpaymentservice.bbps.util;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.ArrayList;
|
||||
@@ -719,9 +720,9 @@ public class BillerMapperHelper {
|
||||
parent.setActionType(responseWrapper.getActionType());
|
||||
parent.setUserId(responseWrapper.getUserId());
|
||||
// Map incoming DTO date strings into Auditable LocalDateTime fields
|
||||
LocalDateTime parentCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
|
||||
Date parentCreatedOn = parseToDate(responseWrapper.getCreationDate());
|
||||
|
||||
LocalDateTime parentUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
|
||||
Date parentUpdatedOn = parseToDate(responseWrapper.getModifiedDate());
|
||||
parent.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
|
||||
parent.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
|
||||
parent.setReqId(reqId);
|
||||
@@ -963,9 +964,9 @@ public class BillerMapperHelper {
|
||||
|
||||
// DATES
|
||||
// Map incoming DTO date strings into Auditable LocalDateTime fields
|
||||
LocalDateTime bmCreatedOn = parseToLocalDateTime(responseWrapper.getCreationDate());
|
||||
Date bmCreatedOn = parseToDate(responseWrapper.getCreationDate());
|
||||
|
||||
LocalDateTime bmUpdatedOn = parseToLocalDateTime(responseWrapper.getModifiedDate());
|
||||
Date bmUpdatedOn = parseToDate(responseWrapper.getModifiedDate());
|
||||
if (bmUpdatedOn != null) {
|
||||
billMaster.setUpdatedDateTime(bmUpdatedOn);
|
||||
}
|
||||
@@ -977,26 +978,17 @@ public class BillerMapperHelper {
|
||||
|
||||
// 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)
|
||||
OffsetDateTime odt = OffsetDateTime.parse(dateStr);
|
||||
return odt.toLocalDateTime();
|
||||
} catch (Exception e) {
|
||||
try {
|
||||
// Fallback to LocalDateTime without offset
|
||||
return LocalDateTime.parse(dateStr, DateTimeFormatter.ISO_LOCAL_DATE_TIME);
|
||||
} catch (Exception ex) {
|
||||
LOGGER.warn("Unable to parse date string to LocalDateTime: {}", dateStr);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
private Date parseToDate(String dateStr) {
|
||||
try {
|
||||
// example format: 2025-12-17T14:30:45
|
||||
LocalDateTime ldt = LocalDateTime.parse(dateStr);
|
||||
return Date.from(ldt.atZone(ZoneId.systemDefault()).toInstant());
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Convert TransactionMaster to master DTO
|
||||
public TransactionHistoryMasterDTO toDTO(TransactionMaster transactionMaster) {
|
||||
if (transactionMaster == null)
|
||||
@@ -1104,7 +1096,7 @@ public class BillerMapperHelper {
|
||||
.orElse("DUMMY_TXN"));
|
||||
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());
|
||||
Date createdOn =parseToDate(apiResponse.getResponseData().getCreatedOn());
|
||||
|
||||
record.setTxnStatus("PENDING"); } else { record.setAmount("0.00");
|
||||
record.setTxnStatus("PENDING"); }
|
||||
|
||||
Reference in New Issue
Block a user