user id addded in this code
This commit is contained in:
@@ -120,6 +120,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
billMaster.setBillId((String) dataMap.get("billId"));
|
||||
billMaster.setReqId(fetchBillRequest.getReqId());
|
||||
billMaster.setTxnId(txnId);
|
||||
billMaster.setClientUserId(fetchBillRequest.getClientUserId());
|
||||
billMasterRepository.save(billMaster);
|
||||
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
|
||||
|
||||
@@ -131,6 +132,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
billInitiate.setBillId((String) dataMap.get("billId"));
|
||||
billInitiate.setReqId(fetchBillRequest.getReqId());
|
||||
billInitiate.setTxnId(txnId);
|
||||
billInitiate.setClientUserId(fetchBillRequest.getClientUserId());
|
||||
billIntiateRepository.save(billInitiate);
|
||||
LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId());
|
||||
|
||||
@@ -394,7 +396,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
System.out.println("responseWrapper:" + responseWrapper);
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest);
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest,txnId);
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -412,7 +414,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
String mid = billRequest.getMid();
|
||||
String requestJson = helper.convertObjectToJson(billRequest);
|
||||
String requestJson = helper.convertObjectToJson(billRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, billRequest, mid, billId);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||
@@ -452,7 +454,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest);
|
||||
mapperHelper.saveBillValidation(responseWrapper, billRequest,txnId);
|
||||
LOGGER.info("Bill validation saved successfully for billId: {}", billId);
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -484,8 +486,8 @@ public class AgentServiceImpl implements AgentService {
|
||||
String requestJson = helper.convertObjectToJson(billValidateByClientIdRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
|
||||
billValidateByClientIdRequest.getClientReqId());
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET,requestJson);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billValidateByClientIdRequest.getMid(), BBPSConstant.HTTP_GET, requestJson);
|
||||
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
|
||||
@@ -142,8 +142,8 @@ public class AuthServiceImpl implements AuthService {
|
||||
Optional<UserEntity> existing = userRepository.findByMobile(request.getMobile());
|
||||
if (existing.isPresent()) {
|
||||
UserEntity u = existing.get();
|
||||
UserDto dto = new UserDto(u.getId(), u.getMobile(), u.getName(), u.getEmail());
|
||||
AuthResponse ar = new AuthResponse(false, "User already exists", true, dto);
|
||||
UserDto dto = new UserDto(u.getUserId(), u.getMobile(), u.getName(), u.getEmail());
|
||||
AuthResponse ar = new AuthResponse(false, "User already exists", null, dto);
|
||||
return ResponseModel.builder().message(ar.getMessage()).status("Failure").statusCode(409).data(ar)
|
||||
.build();
|
||||
}
|
||||
@@ -151,9 +151,11 @@ public class AuthServiceImpl implements AuthService {
|
||||
UserEntity userEntity = helper.createNewUser(request);
|
||||
userRepository.save(userEntity);
|
||||
String token = jwtUtil.generateToken(userEntity.getMobile());
|
||||
UserDto dto = new UserDto(userEntity.getId(), userEntity.getMobile(), userEntity.getName(),
|
||||
userEntity.getEmail());
|
||||
AuthResponse ar = new AuthResponse(true, "user registed sucessfully", token);
|
||||
// UserDto dto = new UserDto(userEntity.getUserId(), userEntity.getMobile(), userEntity.getName(),
|
||||
// userEntity.getEmail());
|
||||
Object userDetailsDTO = helper.mapUserToUserDetailsDTO(userEntity);
|
||||
AuthResponse ar = new AuthResponse(true, "user registered successfully", token, userDetailsDTO);
|
||||
|
||||
return ResponseModel.builder().message(ar.getMessage()).status("Success").statusCode(201).data(ar).build();
|
||||
} catch (ExpiredJwtException e) {
|
||||
LOGGER.error("Token has expired: {}", e.getMessage());
|
||||
|
||||
@@ -8,6 +8,9 @@ import java.util.Optional;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.RestClient;
|
||||
@@ -216,8 +219,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String complaintId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
String ticketId = request.getTicketId();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String userId = request.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={} | userId={}", apiName, reqId, mid, ticketId, userId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
@@ -277,7 +280,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TicketCheckStatusResponse.class);
|
||||
|
||||
String saveComplaintStatus = mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
|
||||
String saveComplaintStatus = mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId, userId);
|
||||
LOGGER.info("[{}] Save Status | ticketId={} | status={}", apiName, ticketId, saveComplaintStatus);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
|
||||
@@ -298,8 +301,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String userId = request.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={} | userId={}", apiName, reqId, mid, ticketId, userId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId();
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
@@ -345,7 +348,7 @@ 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);
|
||||
String saveComplaintHistory = mapperHelper.saveComplaintHistory(responseWrapper, reqId, txnId, userId);
|
||||
LOGGER.info("[{}] Complaint history saved | ticketId={} | entryId={}", apiName, ticketId,
|
||||
saveComplaintHistory);
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -364,7 +367,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String userId = request.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={} | userId={}", apiName, reqId, mid, ticketId, userId);
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
|
||||
@@ -408,7 +412,7 @@ 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);
|
||||
String saveComplaint = mapperHelper.saveComplainStatusDetail(responseWrapper, reqId, txnId, userId);
|
||||
LOGGER.info("[{}] Complaint details saved | ticketId={} | id={}", apiName, ticketId, saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -540,8 +544,9 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String reqId = request.getReqId();
|
||||
String mid = request.getMid();
|
||||
String statusType = request.getStatusType();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | statusType={}", apiName, reqId, mid, statusType);
|
||||
String userId = request.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | statusType={} | userId={}", apiName, reqId, mid, statusType,
|
||||
userId);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
|
||||
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
||||
@@ -586,7 +591,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||
|
||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId, userId);
|
||||
LOGGER.info("[{}] Complaint records saved into DB | count={}", apiName, saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -632,7 +637,12 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
// Log the call to external API
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, apiName);
|
||||
List<ComplaintResponseEntity> complaintUserData = complaintResponseRepository.findByUserIdCustom(userId);
|
||||
// List<ComplaintResponseEntity> complaintUserData =
|
||||
// complaintResponseRepository.findByUserIdCustom(userId);
|
||||
|
||||
Pageable pageable = PageRequest.of(request.getPageNo(), request.getPageSize());
|
||||
Page<ComplaintResponseEntity> complaintUserData = complaintResponseRepository.findByUserIdCustom(userId,
|
||||
pageable);
|
||||
|
||||
// Check if complaints were found
|
||||
if (complaintUserData == null || complaintUserData.isEmpty()) {
|
||||
@@ -642,15 +652,17 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
}
|
||||
|
||||
// Log the number of complaints fetched
|
||||
LOGGER.info("[{}] Complaints found for userId={} | count={}", apiName, userId, complaintUserData.size());
|
||||
LOGGER.info("[{}] Complaints found for userId={} | count={}", apiName, userId,
|
||||
complaintUserData.getContent().size());
|
||||
|
||||
// Update outbound log with the count
|
||||
String count = String.valueOf(complaintUserData.size());
|
||||
String count = String.valueOf(complaintUserData.getContent().size());
|
||||
helper.updateOutboundLogResponse(outboundLog, count);
|
||||
|
||||
// Return successful response with complaints data
|
||||
return new ResponseModel(BBPSConstant.ALL_COMPLAINT_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
BBPSConstant.HTTP_OK_INT, complaintUserData, complaintUserData.size());
|
||||
BBPSConstant.HTTP_OK_INT, complaintUserData.getContent(), // Only the list of complaints (data)
|
||||
complaintUserData.getContent().size());
|
||||
|
||||
} catch (CustomException e) {
|
||||
// Rethrow custom exception for handling at the controller level
|
||||
|
||||
@@ -220,7 +220,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
|
||||
//mapperHelper.saveOrUpdateBillerData(entity);
|
||||
// mapperHelper.saveOrUpdateBillerData(entity);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
@@ -439,7 +439,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
String mid = dispositionDetailRequest.getMid();
|
||||
String requestJson = helper.convertObjectToJson(dispositionDetailRequest);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
String userId = dispositionDetailRequest.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | userId={}", apiName, requestId, mid, userId);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
@@ -474,15 +475,23 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream()
|
||||
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList());
|
||||
// Assuming responseWrapper contains the data you need to map to
|
||||
// DispositionDetails
|
||||
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream().map(dto -> {
|
||||
DispositionDetails disposition = mapper.map(dto, DispositionDetails.class);
|
||||
disposition.setReqId(requestId);
|
||||
disposition.setTxnId(txnID);
|
||||
disposition.setUserId(userId);
|
||||
|
||||
return disposition;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
LOGGER.info("[{}] Dispositions Received: {}", apiName, entities.size());
|
||||
if (entities != null) {
|
||||
dispositionRepository.saveAll(entities);
|
||||
} else {
|
||||
|
||||
LOGGER.warn("No disposition found in response to save.");
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
dispositionRepository.saveAll(entities); // Save the list of entities
|
||||
} else {
|
||||
LOGGER.warn("No dispositions found in response to save.");
|
||||
}
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -506,9 +515,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String apiName = BBPSConstant.API_FETCH_CUSTOMER_PARAM_GROUP;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
String userId = requestModel.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId(), userId);
|
||||
helper.validateMerchant(mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
||||
@@ -543,7 +552,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
CustomerParamGroupsDTO responseDTO = mapperHelper
|
||||
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID);
|
||||
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID, userId);
|
||||
|
||||
LOGGER.info("[{}] Saved {} Customer Param Group records | reqId={}", apiName, responseDTO.toString(),
|
||||
requestId);
|
||||
@@ -569,9 +578,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String apiName = BBPSConstant.API_FETCH_ALL_MASTER_AMOUNT_OPTION;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
String userId = requestModel.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId(), userId);
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
||||
@@ -607,8 +616,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class);
|
||||
|
||||
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
|
||||
txnID);
|
||||
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId, txnID,
|
||||
userId);
|
||||
LOGGER.info("[{}] Save Result | reqId={} | result={}", apiName, requestId, saveAmountOptionsResponse);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
@@ -635,8 +644,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String apiName = BBPSConstant.API_FETCH_PLAN_CATEGORIES;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
String userId = requestModel.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId(), userId);
|
||||
helper.validateMerchant(requestModel.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
|
||||
@@ -672,7 +682,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
|
||||
|
||||
String saveCategoryItems = mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId,
|
||||
txnID);
|
||||
txnID, userId);
|
||||
LOGGER.info("[{}] Saved category items | reqId={} | count={}", apiName, requestId, saveCategoryItems);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
@@ -754,8 +764,9 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String apiName = BBPSConstant.API_FETCH_PLAN_BY_CATEGORIES;
|
||||
String requestId = requestModel.getReqId();
|
||||
String mid = requestModel.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId());
|
||||
String userId = requestModel.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
|
||||
requestModel.getBillerId(), userId);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
|
||||
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
|
||||
@@ -802,7 +813,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
PlanResponses savePlanResponse = mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
|
||||
PlanResponses savePlanResponse = mapperHelper.savePlanResponse(responseWrapper, requestId, txnID, userId);
|
||||
LOGGER.info("[{}] Saved Plans | reqId={} | count={}", apiName, requestId, savePlanResponse);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
@@ -824,8 +835,8 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
|
||||
String requestId = dispositionDetailRequest.getReqId();
|
||||
String mid = dispositionDetailRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
String userId = dispositionDetailRequest.getClientUserId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | userId={}", apiName, requestId, mid, userId);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
@@ -862,7 +873,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID);
|
||||
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID, userId);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -45,355 +45,361 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
@Service
|
||||
public class PaymentServiceImpl implements PaymentService {
|
||||
@Value("${payment.data.url}")
|
||||
private String paymentUrl;
|
||||
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final PaymentRepository paymentRepository;
|
||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
// Shared reusable instances
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
||||
|
||||
public PaymentServiceImpl(BharatConnectMasterRepository beneficiaryDetailsRepository, HttpService httpService,
|
||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
||||
TransactionMasterRepository transactionMasterRepository,
|
||||
AgentFundTransferRepository agentFundTransferRepository,
|
||||
BillerMapperHelper mapperHelper) {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.paymentRepository = paymentRepository;
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||
this.mapperHelper = mapperHelper;
|
||||
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
this.modelMapper = new ModelMapper();
|
||||
this.modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = BBPSConstant.API_INITIATE_PAYMENT;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
billPaymentRequest.setClientReqId(txnId);
|
||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
BillPaymentForwardRequest forwardReq = mapperHelper.billPaymentForwardRequest(billPaymentRequest);
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST, forwardjson);
|
||||
LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Payment API Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for txnId={}", txnId);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS, BBPSConstant.FAILED_STR);
|
||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||
throw new CustomException(BBPSConstant.EMPTY_RESPONSE_FROM_BBPS);
|
||||
}
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_STRUCTURE);
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException(BBPSConstant.INVALID_STRUCTURE);
|
||||
}
|
||||
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
|
||||
BillPayment entity = modelMapper.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.setMid(billPaymentRequest.getMid());
|
||||
paymentInitiate.setClientUserId(billPaymentRequest.getClientUserId());
|
||||
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);
|
||||
transactionStatusRequest.setMid(billPaymentRequest.getMid());
|
||||
transactionStatusRequest.setClientUserId(billPaymentRequest.getClientUserId());
|
||||
|
||||
|
||||
try {
|
||||
Thread.sleep((long) BBPSConstant.PAYMENT_STATUS_DELAY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
LOGGER.info("[{}] END | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_STATUS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
// START log for internal transaction status check
|
||||
LOGGER.info("[{}] START (internal) | checkTxnId={} | reqId={} | bankTxnId={}", apiName, txnId, requestId, transactionStatusRequest.getTxnId());
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created for internal status check | txnId={} | reqId={}", txnId, requestId);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for internal status check | txnId={}", txnId);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.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());
|
||||
|
||||
TransactionMaster transactionMaster = modelMapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class);
|
||||
transactionMaster.setTxnId(txnId);
|
||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||
transactionMaster.setMid(transactionStatusRequest.getMid());
|
||||
transactionMaster.setClientUserId(transactionStatusRequest.getClientUserId());
|
||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||
transactionMasterRepository.save(transactionMaster);
|
||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||
|
||||
AgentFundTransfer agentFundTransfer = modelMapper.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
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END (internal) | checkTxnId={} | reqId={} | status={}", apiName, txnId, requestId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
LOGGER.info("[{}] START (public) | reqId={} | mid={} | checkBankTxnId={}", apiName, requestId, transactionStatusRequest.getMid(), transactionStatusRequest.getTxnId());
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
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();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END (public) | reqId={} | txnId={} | status={}", apiName, requestId, txnID, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_BY_CLIENT_REQ_ID;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId, transactionStatusRequest.getMid(), clientReqId);
|
||||
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL + paymentInitiate.get().getTxnId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(
|
||||
requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(
|
||||
txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
|
||||
LOGGER.debug("Outbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction Status Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(
|
||||
responseData, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
|
||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}",
|
||||
clientReqId, responseData);
|
||||
|
||||
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 for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | clientReqId={} | status={}", apiName, requestId, clientReqId, generalResp.getStatus());
|
||||
return new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
@Value("${payment.data.url}")
|
||||
private String paymentUrl;
|
||||
|
||||
private final BharatConnectMasterRepository beneficiaryDetailsRepository;
|
||||
private final HttpService httpService;
|
||||
private final Helper helper;
|
||||
private final PaymentRepository paymentRepository;
|
||||
private final InboundTraceLogRepository inboundTraceLogRepository;
|
||||
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
||||
private final PaymentIntiateRepository paymentIntiateRepository;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
private final AgentFundTransferRepository agentFundTransferRepository;
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
// Shared reusable instances
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ModelMapper modelMapper;
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(PaymentServiceImpl.class);
|
||||
|
||||
public PaymentServiceImpl(BharatConnectMasterRepository beneficiaryDetailsRepository, HttpService httpService,
|
||||
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
|
||||
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
|
||||
TransactionMasterRepository transactionMasterRepository,
|
||||
AgentFundTransferRepository agentFundTransferRepository, BillerMapperHelper mapperHelper) {
|
||||
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
||||
this.httpService = httpService;
|
||||
this.helper = helper;
|
||||
this.paymentRepository = paymentRepository;
|
||||
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
||||
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
||||
this.paymentIntiateRepository = paymentIntiateRepository;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
this.agentFundTransferRepository = agentFundTransferRepository;
|
||||
this.mapperHelper = mapperHelper;
|
||||
|
||||
this.objectMapper = new ObjectMapper();
|
||||
this.objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
|
||||
this.modelMapper = new ModelMapper();
|
||||
this.modelMapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = BBPSConstant.API_INITIATE_PAYMENT;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String userId = billPaymentRequest.getClientReqId();
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
billPaymentRequest.setClientReqId(txnId);
|
||||
LOGGER.info("Initiating payment for reqId={} and txnId={} and userId={}", requestId, txnId, userId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
BillPaymentForwardRequest forwardReq = mapperHelper.billPaymentForwardRequest(billPaymentRequest);
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(),
|
||||
BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST,
|
||||
forwardjson);
|
||||
LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Payment API Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for txnId={}", txnId);
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS,
|
||||
BBPSConstant.FAILED_STR);
|
||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||
throw new CustomException(BBPSConstant.EMPTY_RESPONSE_FROM_BBPS);
|
||||
}
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_STRUCTURE);
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException(BBPSConstant.INVALID_STRUCTURE);
|
||||
}
|
||||
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
|
||||
BillPayment entity = modelMapper.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.setUserId(userId);
|
||||
paymentInitiate.setReqId(requestId);
|
||||
paymentInitiate.setMid(billPaymentRequest.getMid());
|
||||
paymentInitiate.setClientUserId(billPaymentRequest.getClientUserId());
|
||||
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);
|
||||
transactionStatusRequest.setMid(billPaymentRequest.getMid());
|
||||
transactionStatusRequest.setClientUserId(billPaymentRequest.getClientUserId());
|
||||
|
||||
try {
|
||||
Thread.sleep((long) BBPSConstant.PAYMENT_STATUS_DELAY_MS);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
LOGGER.info("[{}] END | reqId={} | txnId={}", apiName, requestId, txnId);
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
|
||||
InboundTraceLog inboundLog) {
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_STATUS;
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
// START log for internal transaction status check
|
||||
LOGGER.info("[{}] START (internal) | checkTxnId={} | reqId={} | bankTxnId={}", apiName, txnId, requestId,
|
||||
transactionStatusRequest.getTxnId());
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
LOGGER.debug("Outbound log created for internal status check | txnId={} | reqId={}", txnId, requestId);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for internal status check | txnId={}", txnId);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.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());
|
||||
|
||||
TransactionMaster transactionMaster = modelMapper.map(responseWrapper.getTransactionDAO(),
|
||||
TransactionMaster.class);
|
||||
transactionMaster.setTxnId(txnId);
|
||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||
transactionMaster.setMid(transactionStatusRequest.getMid());
|
||||
transactionMaster.setClientUserId(transactionStatusRequest.getClientUserId());
|
||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||
transactionMasterRepository.save(transactionMaster);
|
||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||
|
||||
AgentFundTransfer agentFundTransfer = modelMapper.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);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END (internal) | checkTxnId={} | reqId={} | status={}", apiName, txnId, requestId,
|
||||
generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
LOGGER.info("[{}] START (public) | reqId={} | mid={} | checkBankTxnId={}", apiName, requestId,
|
||||
transactionStatusRequest.getMid(), transactionStatusRequest.getTxnId());
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
LOGGER.debug("Outbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for public status check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData,
|
||||
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
|
||||
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();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END (public) | reqId={} | txnId={} | status={}", apiName, requestId, txnID,
|
||||
generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(
|
||||
TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = BBPSConstant.API_CHECK_BY_CLIENT_REQ_ID;
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId,
|
||||
transactionStatusRequest.getMid(), clientReqId);
|
||||
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
throw new CustomException(BBPSConstant.NO_BILL_FOUND);
|
||||
}
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL
|
||||
+ paymentInitiate.get().getTxnId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
|
||||
HttpHeaders headers = helper.buildHeaders(headersData);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
|
||||
LOGGER.debug("Inbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET,
|
||||
null);
|
||||
LOGGER.debug("Outbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
|
||||
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
|
||||
LOGGER.info("Transaction Status Response: {}", responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
LOGGER.debug("Outbound log response updated for clientReqId check | reqId={} | txnId={}", requestId, txnID);
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
|
||||
|
||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}", clientReqId,
|
||||
responseData);
|
||||
|
||||
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 for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | clientReqId={} | status={}", apiName, requestId, clientReqId,
|
||||
generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -4,7 +4,9 @@ import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.PageRequest;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.TransactionHistoryMasterDTO;
|
||||
import com.billpaymentservice.bbps.dto.TransactionHistoryParticularDetailsDTO;
|
||||
@@ -57,22 +59,34 @@ public class TxnHistoryServiceImpl implements TxnHistoryService {
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
List<TransactionMaster> dataResult = transactionMasterRepository.findByMidOrClientUserId(mid, clientUserId);
|
||||
Page<TransactionMaster> dataResult;
|
||||
if (clientUserId.isEmpty() || clientUserId == null) {
|
||||
Pageable pageable = PageRequest.of(paymentHistoryRequest.getPageNo(),
|
||||
paymentHistoryRequest.getPageSize());
|
||||
dataResult = transactionMasterRepository.findByMid(mid, pageable);
|
||||
} else {
|
||||
Pageable pageable = PageRequest.of(paymentHistoryRequest.getPageNo(),
|
||||
paymentHistoryRequest.getPageSize());
|
||||
dataResult = transactionMasterRepository.findByMidOrClientUserId(mid, clientUserId, pageable);
|
||||
|
||||
}
|
||||
// List<TransactionMaster> dataResult =
|
||||
// transactionMasterRepository.findByMidOrClientUserId(mid, clientUserId);
|
||||
|
||||
if (dataResult == null || dataResult.isEmpty()) {
|
||||
log.info("[{}] Response Fetch From DB | reqId={} | data={}", apiName, requestId, dataResult);
|
||||
throw new CustomException("No Transcation Found This Mid", "FAILED", BBPSConstant.BADREQUEST, null);
|
||||
}
|
||||
|
||||
Integer responseData = dataResult.size();
|
||||
log.info("[{}] Response Fetch From DB | reqId={} | data={}", apiName, requestId, responseData);
|
||||
log.info("[{}] Response Fetch From DB | reqId={} | data={}", apiName, requestId,
|
||||
dataResult.getTotalElements());
|
||||
|
||||
List<TransactionHistoryParticularDetailsDTO> responseDatas = dataResult.stream()
|
||||
.map(mapperHelper::billerRemainingDetails).collect(Collectors.toList());
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, String.valueOf(responseData));
|
||||
helper.updateOutboundLogResponse(outboundLog, String.valueOf(dataResult.getTotalElements()));
|
||||
|
||||
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
return new ResponseModel(BBPSConstant.ALL_HISTORY_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
BBPSConstant.HTTP_OK_INT, responseDatas, responseDatas.size());
|
||||
|
||||
} catch (CustomException e) {
|
||||
@@ -123,7 +137,7 @@ public class TxnHistoryServiceImpl implements TxnHistoryService {
|
||||
helper.updateOutboundLogResponse(outboundLog, String.valueOf(responseData));
|
||||
|
||||
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
BBPSConstant.HTTP_OK_INT, transactionDTO,null,responseData);
|
||||
BBPSConstant.HTTP_OK_INT, transactionDTO, null, responseData);
|
||||
|
||||
} catch (CustomException e) {
|
||||
// Log and rethrow the custom exception
|
||||
|
||||
Reference in New Issue
Block a user