user id addded in this code

This commit is contained in:
Mohd-Arham
2025-12-03 17:40:04 +05:30
parent d521459227
commit 003dd9325c
33 changed files with 723 additions and 568 deletions
@@ -39,6 +39,8 @@ public class SecurityConfig {
"/swagger-resources/**", "/swagger-resources/**",
"/webjars/**", "/webjars/**",
"/error") "/error")
.permitAll()
.requestMatchers("/payment/callback/startPayment")
.permitAll().requestMatchers(HttpMethod.OPTIONS, "/**").permitAll() .permitAll().requestMatchers(HttpMethod.OPTIONS, "/**").permitAll()
.anyRequest().authenticated()) .anyRequest().authenticated())
.exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint)) .exceptionHandling(ex -> ex.authenticationEntryPoint(jwtAuthenticationEntryPoint))
@@ -98,7 +98,8 @@ public class AgentController {
} }
@PostMapping(value = "/callback/billValidate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @PostMapping(value = "/callback/billValidate", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<ResponseModel> handleBillValidateCallback(@RequestBody FetchBillValidateResponse fetchBillValidateResponse) { public ResponseEntity<ResponseModel> handleBillValidateCallback(
@RequestBody FetchBillValidateResponse fetchBillValidateResponse) {
ResponseModel genralResp = agentService.processBillValidateCallback(fetchBillValidateResponse); ResponseModel genralResp = agentService.processBillValidateCallback(fetchBillValidateResponse);
// Return a response indicating successful receipt // Return a response indicating successful receipt
return ResponseEntity.ok(genralResp); return ResponseEntity.ok(genralResp);
@@ -16,15 +16,16 @@ public class AuthResponse {
private boolean success; private boolean success;
private String message; private String message;
private boolean userExists; private boolean userExists;
private UserDto user; private Object user;
private String token; private String token;
public AuthResponse(boolean success, String message, boolean userExists, UserDto user) { public AuthResponse(boolean success, String message, String token, Object user) {
this.success = success; this.success = success;
this.message = message; this.message = message;
this.userExists = userExists; this.token = token;
this.user = user; this.user = user;
} }
public AuthResponse(boolean success, String message, String token) { public AuthResponse(boolean success, String message, String token) {
this.success = success; this.success = success;
this.message = message; this.message = message;
@@ -10,7 +10,7 @@ import lombok.Setter;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class UserDto { public class UserDto {
private Long id; private String userId;
private String mobile; private String mobile;
private String name; private String name;
private String email; private String email;
@@ -1,5 +1,7 @@
package com.billpaymentservice.bbps.dto.request; package com.billpaymentservice.bbps.dto.request;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -7,4 +9,10 @@ import lombok.Setter;
@Setter @Setter
public class AllMasterOptionsRequest extends BaseClass { public class AllMasterOptionsRequest extends BaseClass {
private Integer pageNo = 0;
@NotNull(message = "pageEnd is required")
@Min(value = 1, message = "pageEnd must be greater than 0")
private Integer pageSize;
} }
@@ -1,5 +1,7 @@
package com.billpaymentservice.bbps.dto.request; package com.billpaymentservice.bbps.dto.request;
import jakarta.validation.constraints.Min;
import jakarta.validation.constraints.NotNull;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@@ -7,4 +9,10 @@ import lombok.Setter;
@Setter @Setter
public class PaymentHistoryRequest extends BaseClass { public class PaymentHistoryRequest extends BaseClass {
private Integer pageNo = 0;
@NotNull(message = "pageEnd is required")
@Min(value = 1, message = "pageEnd must be greater than 0")
private Integer pageSize;
} }
@@ -35,4 +35,7 @@ public class AmountOptionDetails {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -1,4 +1,5 @@
package com.billpaymentservice.bbps.entites; package com.billpaymentservice.bbps.entites;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@@ -23,4 +24,7 @@ public class BillInitiate {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "client_user_id")
private String clientUserId;
} }
@@ -1,7 +1,9 @@
package com.billpaymentservice.bbps.entites; 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.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
import jakarta.persistence.JoinColumn; import jakarta.persistence.JoinColumn;
@@ -32,6 +34,7 @@ public class BillMaster {
private String billerId; private String billerId;
private String status; private String status;
private String actionType; private String actionType;
private String clientUserId;
private String userId; private String userId;
@OneToOne(cascade = CascadeType.ALL) @OneToOne(cascade = CascadeType.ALL)
@JoinColumn(name = "biller_response_id") @JoinColumn(name = "biller_response_id")
@@ -1,6 +1,5 @@
package com.billpaymentservice.bbps.entites; package com.billpaymentservice.bbps.entites;
import java.util.List; import java.util.List;
import jakarta.persistence.*; import jakarta.persistence.*;
@@ -58,4 +57,13 @@ public class BillValidation {
@Column(name = "modified_epoch_date", length = 50) @Column(name = "modified_epoch_date", length = 50)
private String modifiedEpochDate; private String modifiedEpochDate;
@Column(name = "txn_id")
private String txnId;
@Column(name = "req_id")
private String reqId;
@Column(name = "client_user_id")
private String clientUserId;
} }
@@ -30,4 +30,7 @@ public class CategoryResponseList extends Auditable<String> {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -68,4 +68,7 @@ public class ComplainStatus extends Auditable<String> {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -43,5 +43,7 @@ public class ComplaintHistory extends Auditable<String> {
@Column(name = "req_id") @Column(name = "req_id")
private String reqId; private String reqId;
@Column(name = "user_id")
private String userId;
} }
@@ -10,10 +10,12 @@ import jakarta.persistence.Id;
import jakarta.persistence.Table; import jakarta.persistence.Table;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
import lombok.ToString;
@Entity @Entity
@Getter @Getter
@Setter @Setter
@ToString
@Table(name = "complaint_responses") @Table(name = "complaint_responses")
public class ComplaintResponseEntity extends Auditable<String> { public class ComplaintResponseEntity extends Auditable<String> {
@@ -27,6 +27,9 @@ public class ComplaintStatusDetails extends Auditable<String>{
@Column(name = "txn_id") @Column(name = "txn_id")
private String systemTxnId; private String systemTxnId;
@Column(name = "user_id")
private String userId;
@Column(name = "total_elements") @Column(name = "total_elements")
private String totalElements; private String totalElements;
@@ -56,4 +56,6 @@ public class CustomerParamGroupById extends Auditable<String> {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -24,4 +24,13 @@ public class DispositionDetails {
@Column(name = "tenant_id") @Column(name = "tenant_id")
private String tenantId; private String tenantId;
@Column(name = "req_id")
private String reqId;
@Column(name = "txn_id")
private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -8,7 +8,6 @@ import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@Data @Data
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
@@ -34,4 +33,7 @@ public class PaymentInitiate {
@Column(name = "status") @Column(name = "status")
private String status; private String status;
@Column(name = "user_id")
private String userId;
} }
@@ -47,4 +47,7 @@ public class PlanResponses extends Auditable<String> {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -41,4 +41,6 @@ public class TicketDispositionDetails extends Auditable<String> {
@Column(name = "txn_id") @Column(name = "txn_id")
private String txnId; private String txnId;
@Column(name = "user_id")
private String userId;
} }
@@ -27,6 +27,9 @@ public class ViewAllComplaintTicketStatusDetails extends Auditable<String> {
@Column(name = "txn_id") @Column(name = "txn_id")
private String systemTxnId; private String systemTxnId;
@Column(name = "user_id")
private String userId;
@Column(name = "total_elements") @Column(name = "total_elements")
private String totalElements; private String totalElements;
@@ -1,7 +1,7 @@
package com.billpaymentservice.bbps.repository; package com.billpaymentservice.bbps.repository;
import java.util.List; import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
@@ -12,6 +12,9 @@ import com.billpaymentservice.bbps.entites.ComplaintResponseEntity;
@Repository @Repository
public interface ComplaintResponseRepository extends JpaRepository<ComplaintResponseEntity, Long> { public interface ComplaintResponseRepository extends JpaRepository<ComplaintResponseEntity, Long> {
// @Query("SELECT c FROM ComplaintResponseEntity c WHERE c.userId = :userId")
// List<ComplaintResponseEntity> findByUserIdCustom(@Param("userId") String userId);
@Query("SELECT c FROM ComplaintResponseEntity c WHERE c.userId = :userId") @Query("SELECT c FROM ComplaintResponseEntity c WHERE c.userId = :userId")
List<ComplaintResponseEntity> findByUserIdCustom(@Param("userId") String userId); Page<ComplaintResponseEntity> findByUserIdCustom(@Param("userId") String userId, Pageable pageable);
} }
@@ -6,13 +6,23 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query; import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param; import org.springframework.data.repository.query.Param;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import com.billpaymentservice.bbps.entites.TransactionMaster; import com.billpaymentservice.bbps.entites.TransactionMaster;
public interface TransactionMasterRepository extends JpaRepository<TransactionMaster, String> { public interface TransactionMasterRepository extends JpaRepository<TransactionMaster, String> {
@Query("SELECT t FROM TransactionMaster t WHERE t.mid = :mid OR t.clientUserId = :clientUserId") // @Query("SELECT t FROM TransactionMaster t WHERE t.mid = :mid OR t.clientUserId = :clientUserId")
List<TransactionMaster> findByMidOrClientUserId(@Param("mid") String mid, // List<TransactionMaster> findByMidOrClientUserId(@Param("mid") String mid,
@Param("clientUserId") String clientUserId); // @Param("clientUserId") String clientUserId);
//
@Query("SELECT t FROM TransactionMaster t WHERE t.mid = :mid")
Page<TransactionMaster> findByMid(@Param("mid") String mid, Pageable pageable);
@Query("SELECT t FROM TransactionMaster t WHERE t.mid = :mid AND t.clientUserId = :clientUserId")
Page<TransactionMaster> findByMidOrClientUserId(@Param("mid") String mid,
@Param("clientUserId") String clientUserId, Pageable pageable);
@Query("SELECT t FROM TransactionMaster t WHERE t.txnId = :txnId") @Query("SELECT t FROM TransactionMaster t WHERE t.txnId = :txnId")
List<TransactionMaster> findByTxnId(@Param("txnId") String txnId); List<TransactionMaster> findByTxnId(@Param("txnId") String txnId);
@@ -120,6 +120,7 @@ public class AgentServiceImpl implements AgentService {
billMaster.setBillId((String) dataMap.get("billId")); billMaster.setBillId((String) dataMap.get("billId"));
billMaster.setReqId(fetchBillRequest.getReqId()); billMaster.setReqId(fetchBillRequest.getReqId());
billMaster.setTxnId(txnId); billMaster.setTxnId(txnId);
billMaster.setClientUserId(fetchBillRequest.getClientUserId());
billMasterRepository.save(billMaster); billMasterRepository.save(billMaster);
LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId()); LOGGER.info("BillMaster saved for billId: {}", billMaster.getBillId());
@@ -131,6 +132,7 @@ public class AgentServiceImpl implements AgentService {
billInitiate.setBillId((String) dataMap.get("billId")); billInitiate.setBillId((String) dataMap.get("billId"));
billInitiate.setReqId(fetchBillRequest.getReqId()); billInitiate.setReqId(fetchBillRequest.getReqId());
billInitiate.setTxnId(txnId); billInitiate.setTxnId(txnId);
billInitiate.setClientUserId(fetchBillRequest.getClientUserId());
billIntiateRepository.save(billInitiate); billIntiateRepository.save(billInitiate);
LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId()); LOGGER.info("BillInitiate entry saved for billId: {}", billInitiate.getBillId());
@@ -394,7 +396,7 @@ public class AgentServiceImpl implements AgentService {
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
System.out.println("responseWrapper:" + responseWrapper); System.out.println("responseWrapper:" + responseWrapper);
mapperHelper.saveBillValidation(responseWrapper, billRequest); mapperHelper.saveBillValidation(responseWrapper, billRequest,txnId);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper); Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
@@ -452,7 +454,7 @@ public class AgentServiceImpl implements AgentService {
GeneralResp generalResp = responseWrapper.getGenericResponse(); GeneralResp generalResp = responseWrapper.getGenericResponse();
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); 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("Bill validation saved successfully for billId: {}", billId);
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus()); LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -142,8 +142,8 @@ public class AuthServiceImpl implements AuthService {
Optional<UserEntity> existing = userRepository.findByMobile(request.getMobile()); Optional<UserEntity> existing = userRepository.findByMobile(request.getMobile());
if (existing.isPresent()) { if (existing.isPresent()) {
UserEntity u = existing.get(); UserEntity u = existing.get();
UserDto dto = new UserDto(u.getId(), u.getMobile(), u.getName(), u.getEmail()); UserDto dto = new UserDto(u.getUserId(), u.getMobile(), u.getName(), u.getEmail());
AuthResponse ar = new AuthResponse(false, "User already exists", true, dto); AuthResponse ar = new AuthResponse(false, "User already exists", null, dto);
return ResponseModel.builder().message(ar.getMessage()).status("Failure").statusCode(409).data(ar) return ResponseModel.builder().message(ar.getMessage()).status("Failure").statusCode(409).data(ar)
.build(); .build();
} }
@@ -151,9 +151,11 @@ public class AuthServiceImpl implements AuthService {
UserEntity userEntity = helper.createNewUser(request); UserEntity userEntity = helper.createNewUser(request);
userRepository.save(userEntity); userRepository.save(userEntity);
String token = jwtUtil.generateToken(userEntity.getMobile()); String token = jwtUtil.generateToken(userEntity.getMobile());
UserDto dto = new UserDto(userEntity.getId(), userEntity.getMobile(), userEntity.getName(), // UserDto dto = new UserDto(userEntity.getUserId(), userEntity.getMobile(), userEntity.getName(),
userEntity.getEmail()); // userEntity.getEmail());
AuthResponse ar = new AuthResponse(true, "user registed sucessfully", token); 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(); return ResponseModel.builder().message(ar.getMessage()).status("Success").statusCode(201).data(ar).build();
} catch (ExpiredJwtException e) { } catch (ExpiredJwtException e) {
LOGGER.error("Token has expired: {}", e.getMessage()); LOGGER.error("Token has expired: {}", e.getMessage());
@@ -8,6 +8,9 @@ import java.util.Optional;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; 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.http.HttpHeaders;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestClient; import org.springframework.web.client.RestClient;
@@ -216,8 +219,8 @@ public class ComplainServiceImpl implements ComplainService {
String complaintId = request.getTicketId(); String complaintId = request.getTicketId();
String mid = request.getMid(); String mid = request.getMid();
String ticketId = request.getTicketId(); String ticketId = request.getTicketId();
String userId = request.getClientUserId();
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId); LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={} | userId={}", apiName, reqId, mid, ticketId, userId);
String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS; String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
String txnId = helper.generateTxnId(15); String txnId = helper.generateTxnId(15);
@@ -277,7 +280,7 @@ public class ComplainServiceImpl implements ComplainService {
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
TicketCheckStatusResponse.class); 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); LOGGER.info("[{}] Save Status | ticketId={} | status={}", apiName, ticketId, saveComplaintStatus);
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus()); helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
@@ -298,8 +301,8 @@ public class ComplainServiceImpl implements ComplainService {
String reqId = request.getReqId(); String reqId = request.getReqId();
String ticketId = request.getTicketId(); String ticketId = request.getTicketId();
String mid = request.getMid(); String mid = request.getMid();
String userId = request.getClientUserId();
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId); LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={} | userId={}", apiName, reqId, mid, ticketId, userId);
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId(); String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId();
String txnId = helper.generateTxnId(15); String txnId = helper.generateTxnId(15);
@@ -345,7 +348,7 @@ public class ComplainServiceImpl implements ComplainService {
LOGGER.info("Current Complaint ReOpen Status: {}", status); LOGGER.info("Current Complaint ReOpen Status: {}", status);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); 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, LOGGER.info("[{}] Complaint history saved | ticketId={} | entryId={}", apiName, ticketId,
saveComplaintHistory); saveComplaintHistory);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -364,7 +367,8 @@ public class ComplainServiceImpl implements ComplainService {
String reqId = request.getReqId(); String reqId = request.getReqId();
String ticketId = request.getTicketId(); String ticketId = request.getTicketId();
String mid = request.getMid(); 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 txnId = helper.generateTxnId(15);
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId(); 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); LOGGER.info("Current Complaint ReOpen Status: {}", status);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); 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); LOGGER.info("[{}] Complaint details saved | ticketId={} | id={}", apiName, ticketId, saveComplaint);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -540,8 +544,9 @@ public class ComplainServiceImpl implements ComplainService {
String reqId = request.getReqId(); String reqId = request.getReqId();
String mid = request.getMid(); String mid = request.getMid();
String statusType = request.getStatusType(); String statusType = request.getStatusType();
String userId = request.getClientUserId();
LOGGER.info("[{}] START | reqId={} | mid={} | statusType={}", apiName, reqId, mid, statusType); LOGGER.info("[{}] START | reqId={} | mid={} | statusType={} | userId={}", apiName, reqId, mid, statusType,
userId);
String txnId = helper.generateTxnId(15); String txnId = helper.generateTxnId(15);
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo() String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType=" + "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
@@ -586,7 +591,7 @@ public class ComplainServiceImpl implements ComplainService {
String status = generalResp.getStatus(); String status = generalResp.getStatus();
LOGGER.info("Current Complaint ReOpen Status: {}", status); 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); LOGGER.info("[{}] Complaint records saved into DB | count={}", apiName, saveComplaint);
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -632,7 +637,12 @@ public class ComplainServiceImpl implements ComplainService {
// Log the call to external API // Log the call to external API
LOGGER.info("[{}] Calling external API | URL={}", apiName, apiName); 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 // Check if complaints were found
if (complaintUserData == null || complaintUserData.isEmpty()) { if (complaintUserData == null || complaintUserData.isEmpty()) {
@@ -642,15 +652,17 @@ public class ComplainServiceImpl implements ComplainService {
} }
// Log the number of complaints fetched // 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 // Update outbound log with the count
String count = String.valueOf(complaintUserData.size()); String count = String.valueOf(complaintUserData.getContent().size());
helper.updateOutboundLogResponse(outboundLog, count); helper.updateOutboundLogResponse(outboundLog, count);
// Return successful response with complaints data // Return successful response with complaints data
return new ResponseModel(BBPSConstant.ALL_COMPLAINT_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE, 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) { } catch (CustomException e) {
// Rethrow custom exception for handling at the controller level // Rethrow custom exception for handling at the controller level
@@ -439,7 +439,8 @@ public class MasterDataServiceImpl implements MasterDataService {
String requestId = dispositionDetailRequest.getReqId(); String requestId = dispositionDetailRequest.getReqId();
String mid = dispositionDetailRequest.getMid(); String mid = dispositionDetailRequest.getMid();
String requestJson = helper.convertObjectToJson(dispositionDetailRequest); 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 txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL; String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
@@ -474,15 +475,23 @@ public class MasterDataServiceImpl implements MasterDataService {
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper(); ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream() // Assuming responseWrapper contains the data you need to map to
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList()); // 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()); 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(), 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 apiName = BBPSConstant.API_FETCH_CUSTOMER_PARAM_GROUP;
String requestId = requestModel.getReqId(); String requestId = requestModel.getReqId();
String mid = requestModel.getMid(); String mid = requestModel.getMid();
String userId = requestModel.getClientUserId();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
requestModel.getBillerId()); requestModel.getBillerId(), userId);
helper.validateMerchant(mid); helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId(); String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
@@ -543,7 +552,7 @@ public class MasterDataServiceImpl implements MasterDataService {
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
CustomerParamGroupsDTO responseDTO = mapperHelper 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(), LOGGER.info("[{}] Saved {} Customer Param Group records | reqId={}", apiName, responseDTO.toString(),
requestId); requestId);
@@ -569,9 +578,9 @@ public class MasterDataServiceImpl implements MasterDataService {
String apiName = BBPSConstant.API_FETCH_ALL_MASTER_AMOUNT_OPTION; String apiName = BBPSConstant.API_FETCH_ALL_MASTER_AMOUNT_OPTION;
String requestId = requestModel.getReqId(); String requestId = requestModel.getReqId();
String mid = requestModel.getMid(); String mid = requestModel.getMid();
String userId = requestModel.getClientUserId();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
requestModel.getBillerId()); requestModel.getBillerId(), userId);
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId(); String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
@@ -607,8 +616,8 @@ public class MasterDataServiceImpl implements MasterDataService {
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class); AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class);
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId, String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId, txnID,
txnID); userId);
LOGGER.info("[{}] Save Result | reqId={} | result={}", apiName, requestId, saveAmountOptionsResponse); LOGGER.info("[{}] Save Result | reqId={} | result={}", apiName, requestId, saveAmountOptionsResponse);
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
@@ -635,8 +644,9 @@ public class MasterDataServiceImpl implements MasterDataService {
String apiName = BBPSConstant.API_FETCH_PLAN_CATEGORIES; String apiName = BBPSConstant.API_FETCH_PLAN_CATEGORIES;
String requestId = requestModel.getReqId(); String requestId = requestModel.getReqId();
String mid = requestModel.getMid(); String mid = requestModel.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, String userId = requestModel.getClientUserId();
requestModel.getBillerId()); LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
requestModel.getBillerId(), userId);
helper.validateMerchant(requestModel.getMid()); helper.validateMerchant(requestModel.getMid());
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId(); String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
@@ -672,7 +682,7 @@ public class MasterDataServiceImpl implements MasterDataService {
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class); PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
String saveCategoryItems = mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId, String saveCategoryItems = mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId,
txnID); txnID, userId);
LOGGER.info("[{}] Saved category items | reqId={} | count={}", apiName, requestId, saveCategoryItems); LOGGER.info("[{}] Saved category items | reqId={} | count={}", apiName, requestId, saveCategoryItems);
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
@@ -754,8 +764,9 @@ public class MasterDataServiceImpl implements MasterDataService {
String apiName = BBPSConstant.API_FETCH_PLAN_BY_CATEGORIES; String apiName = BBPSConstant.API_FETCH_PLAN_BY_CATEGORIES;
String requestId = requestModel.getReqId(); String requestId = requestModel.getReqId();
String mid = requestModel.getMid(); String mid = requestModel.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, String userId = requestModel.getClientUserId();
requestModel.getBillerId()); LOGGER.info("[{}] START | reqId={} | mid={} | billerId={} | userId={}", apiName, requestId, mid,
requestModel.getBillerId(), userId);
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl, String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.PLANS_URL, requestModel.getBillerId(), BBPSConstant.PLANS_URL, requestModel.getBillerId(),
@@ -802,7 +813,7 @@ public class MasterDataServiceImpl implements MasterDataService {
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class); PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp(); 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); LOGGER.info("[{}] Saved Plans | reqId={} | count={}", apiName, requestId, savePlanResponse);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), 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 apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
String requestId = dispositionDetailRequest.getReqId(); String requestId = dispositionDetailRequest.getReqId();
String mid = dispositionDetailRequest.getMid(); String mid = dispositionDetailRequest.getMid();
String userId = dispositionDetailRequest.getClientUserId();
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid); LOGGER.info("[{}] START | reqId={} | mid={} | userId={}", apiName, requestId, mid, userId);
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL; String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
@@ -862,7 +873,7 @@ public class MasterDataServiceImpl implements MasterDataService {
ModelMapper mapper = new ModelMapper(); ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); 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(), ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper); Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
@@ -68,8 +68,7 @@ public class PaymentServiceImpl implements PaymentService {
Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository, Helper helper, PaymentRepository paymentRepository, InboundTraceLogRepository inboundTraceLogRepository,
OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository, OutboundTraceLogRepository outboundTraceLogRepository, PaymentIntiateRepository paymentIntiateRepository,
TransactionMasterRepository transactionMasterRepository, TransactionMasterRepository transactionMasterRepository,
AgentFundTransferRepository agentFundTransferRepository, AgentFundTransferRepository agentFundTransferRepository, BillerMapperHelper mapperHelper) {
BillerMapperHelper mapperHelper) {
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository; this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
this.httpService = httpService; this.httpService = httpService;
this.helper = helper; this.helper = helper;
@@ -93,9 +92,10 @@ public class PaymentServiceImpl implements PaymentService {
String apiName = BBPSConstant.API_INITIATE_PAYMENT; String apiName = BBPSConstant.API_INITIATE_PAYMENT;
String txnId = helper.generateTxnId(15); String txnId = helper.generateTxnId(15);
String requestId = billPaymentRequest.getReqId(); String requestId = billPaymentRequest.getReqId();
String userId = billPaymentRequest.getClientReqId();
String url = paymentUrl + BBPSConstant.PAYMENT_URL; String url = paymentUrl + BBPSConstant.PAYMENT_URL;
billPaymentRequest.setClientReqId(txnId); billPaymentRequest.setClientReqId(txnId);
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId); LOGGER.info("Initiating payment for reqId={} and txnId={} and userId={}", requestId, txnId, userId);
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID); BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData); HttpHeaders headers = helper.buildHeaders(headersData);
@@ -104,9 +104,11 @@ public class PaymentServiceImpl implements PaymentService {
String forwardjson = helper.convertObjectToJson(forwardReq); String forwardjson = helper.convertObjectToJson(forwardReq);
String requestJson = helper.convertObjectToJson(billPaymentRequest); String requestJson = helper.convertObjectToJson(billPaymentRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), BBPSConstant.HTTP_POST, requestJson); 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); LOGGER.debug("Inbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST, forwardjson); OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_POST,
forwardjson);
LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId); LOGGER.debug("Outbound log created for api={} | reqId={} | txnId={}", apiName, requestId, txnId);
try { try {
@@ -119,12 +121,15 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.debug("Outbound log response updated for txnId={}", txnId); LOGGER.debug("Outbound log response updated for txnId={}", txnId);
if (responseData == null || responseData.isEmpty()) { if (responseData == null || responseData.isEmpty()) {
helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS, BBPSConstant.FAILED_STR); helper.updateInboundLogFailure(inboundLog, BBPSConstant.EMPTY_RESPONSE_FROM_BBPS,
BBPSConstant.FAILED_STR);
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId); LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
throw new CustomException(BBPSConstant.EMPTY_RESPONSE_FROM_BBPS); throw new CustomException(BBPSConstant.EMPTY_RESPONSE_FROM_BBPS);
} }
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {}); Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) { if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERIC_KEY)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_STRUCTURE); helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_STRUCTURE);
LOGGER.warn("Invalid response structure received for txnId={}", txnId); LOGGER.warn("Invalid response structure received for txnId={}", txnId);
@@ -141,6 +146,7 @@ public class PaymentServiceImpl implements PaymentService {
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus()); helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
PaymentInitiate paymentInitiate = new PaymentInitiate(); PaymentInitiate paymentInitiate = new PaymentInitiate();
paymentInitiate.setTxnId(txnId); paymentInitiate.setTxnId(txnId);
paymentInitiate.setUserId(userId);
paymentInitiate.setReqId(requestId); paymentInitiate.setReqId(requestId);
paymentInitiate.setMid(billPaymentRequest.getMid()); paymentInitiate.setMid(billPaymentRequest.getMid());
paymentInitiate.setClientUserId(billPaymentRequest.getClientUserId()); paymentInitiate.setClientUserId(billPaymentRequest.getClientUserId());
@@ -155,7 +161,6 @@ public class PaymentServiceImpl implements PaymentService {
transactionStatusRequest.setMid(billPaymentRequest.getMid()); transactionStatusRequest.setMid(billPaymentRequest.getMid());
transactionStatusRequest.setClientUserId(billPaymentRequest.getClientUserId()); transactionStatusRequest.setClientUserId(billPaymentRequest.getClientUserId());
try { try {
Thread.sleep((long) BBPSConstant.PAYMENT_STATUS_DELAY_MS); Thread.sleep((long) BBPSConstant.PAYMENT_STATUS_DELAY_MS);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@@ -173,22 +178,26 @@ public class PaymentServiceImpl implements PaymentService {
} }
} }
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) { public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
InboundTraceLog inboundLog) {
String apiName = BBPSConstant.API_CHECK_TRANSACTION_STATUS; String apiName = BBPSConstant.API_CHECK_TRANSACTION_STATUS;
String txnId = helper.generateTxnId(15); String txnId = helper.generateTxnId(15);
String requestId = transactionStatusRequest.getReqId(); String requestId = transactionStatusRequest.getReqId();
// START log for internal transaction status check // START log for internal transaction status check
LOGGER.info("[{}] START (internal) | checkTxnId={} | reqId={} | bankTxnId={}", apiName, txnId, requestId, transactionStatusRequest.getTxnId()); LOGGER.info("[{}] START (internal) | checkTxnId={} | reqId={} | bankTxnId={}", apiName, txnId, requestId,
transactionStatusRequest.getTxnId());
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId(); String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId); LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
transactionStatusRequest.getTxnId(), requestId);
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID); BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData); HttpHeaders headers = helper.buildHeaders(headersData);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, BBPSConstant.HTTP_GET, null); 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); LOGGER.debug("Outbound log created for internal status check | txnId={} | reqId={}", txnId, requestId);
Map<String, String> responseMap = httpService.getRequest(url, headers); Map<String, String> responseMap = httpService.getRequest(url, headers);
@@ -199,23 +208,24 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.debug("Outbound log response updated for internal status check | txnId={}", txnId); LOGGER.debug("Outbound log response updated for internal status check | txnId={}", txnId);
try { try {
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {}); Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) { if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE); helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId()); LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
throw new CustomException( throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
String.valueOf(dataMap.get("message")),
String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
String.valueOf(dataMap.get("remarks")) String.valueOf(dataMap.get("remarks")));
);
} }
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class); TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
LOGGER.info("Transaction status received: {}", generalResp.getStatus()); LOGGER.info("Transaction status received: {}", generalResp.getStatus());
TransactionMaster transactionMaster = modelMapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class); TransactionMaster transactionMaster = modelMapper.map(responseWrapper.getTransactionDAO(),
TransactionMaster.class);
transactionMaster.setTxnId(txnId); transactionMaster.setTxnId(txnId);
transactionMaster.setReqId(transactionStatusRequest.getReqId()); transactionMaster.setReqId(transactionStatusRequest.getReqId());
transactionMaster.setMid(transactionStatusRequest.getMid()); transactionMaster.setMid(transactionStatusRequest.getMid());
@@ -224,22 +234,20 @@ public class PaymentServiceImpl implements PaymentService {
transactionMasterRepository.save(transactionMaster); transactionMasterRepository.save(transactionMaster);
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId); LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
AgentFundTransfer agentFundTransfer = modelMapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class); AgentFundTransfer agentFundTransfer = modelMapper.map(responseWrapper.getAgentFundTransfer(),
AgentFundTransfer.class);
agentFundTransfer.setTxnId(txnId); agentFundTransfer.setTxnId(txnId);
agentFundTransfer.setReqId(transactionStatusRequest.getReqId()); agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId()); agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
agentFundTransferRepository.save(agentFundTransfer); agentFundTransferRepository.save(agentFundTransfer);
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId); LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
ResponseModel responseModel = new ResponseModel( ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
generalResp.getMessage(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()),
responseWrapper
);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END (internal) | checkTxnId={} | reqId={} | status={}", apiName, txnId, requestId, generalResp.getStatus()); LOGGER.info("[{}] END (internal) | checkTxnId={} | reqId={} | status={}", apiName, txnId, requestId,
generalResp.getStatus());
return responseModel; return responseModel;
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
@@ -255,18 +263,22 @@ public class PaymentServiceImpl implements PaymentService {
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC; String apiName = BBPSConstant.API_CHECK_TRANSACTION_PUBLIC;
String requestId = transactionStatusRequest.getReqId(); String requestId = transactionStatusRequest.getReqId();
LOGGER.info("[{}] START (public) | reqId={} | mid={} | checkBankTxnId={}", apiName, requestId, transactionStatusRequest.getMid(), transactionStatusRequest.getTxnId()); LOGGER.info("[{}] START (public) | reqId={} | mid={} | checkBankTxnId={}", apiName, requestId,
transactionStatusRequest.getMid(), transactionStatusRequest.getTxnId());
String requestJson = helper.convertObjectToJson(transactionStatusRequest); String requestJson = helper.convertObjectToJson(transactionStatusRequest);
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId(); String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId); LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
transactionStatusRequest.getTxnId(), requestId);
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID); BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData); HttpHeaders headers = helper.buildHeaders(headersData);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson); 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); 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); 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); LOGGER.debug("Outbound log created for public status check | reqId={} | txnId={}", requestId, txnID);
Map<String, String> responseMap = httpService.getRequest(url, headers); Map<String, String> responseMap = httpService.getRequest(url, headers);
@@ -276,33 +288,32 @@ public class PaymentServiceImpl implements PaymentService {
LOGGER.debug("Outbound log response updated for public status check | reqId={} | txnId={}", requestId, txnID); LOGGER.debug("Outbound log response updated for public status check | reqId={} | txnId={}", requestId, txnID);
try { try {
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {}); Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) { if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY))); helper.updateInboundLogFailure(inboundLog, responseData,
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", transactionStatusRequest.getTxnId()); String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException( LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
String.valueOf(dataMap.get("message")), transactionStatusRequest.getTxnId());
String.valueOf(dataMap.get("status")), throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
String.valueOf(dataMap.get("remarks")) String.valueOf(dataMap.get("remarks")));
);
} }
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class); TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
String status = generalResp.getStatus(); String status = generalResp.getStatus();
LOGGER.info("Current transaction status: {}", status); LOGGER.info("Current transaction status: {}", status);
ResponseModel responseModel = new ResponseModel( ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
generalResp.getMessage(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()),
responseWrapper
);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END (public) | reqId={} | txnId={} | status={}", apiName, requestId, txnID, generalResp.getStatus()); LOGGER.info("[{}] END (public) | reqId={} | txnId={} | status={}", apiName, requestId, txnID,
generalResp.getStatus());
return responseModel; return responseModel;
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
@@ -313,7 +324,8 @@ public class PaymentServiceImpl implements PaymentService {
} }
@Override @Override
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) { public ResponseModel checkTrasactionStatusByClientReqId(
TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
helper.validateMerchant(transactionStatusRequest.getMid()); helper.validateMerchant(transactionStatusRequest.getMid());
String txnID = helper.generateTxnId(15); String txnID = helper.generateTxnId(15);
@@ -322,24 +334,26 @@ public class PaymentServiceImpl implements PaymentService {
String clientReqId = transactionStatusRequest.getClientReqId(); String clientReqId = transactionStatusRequest.getClientReqId();
String requestJson = helper.convertObjectToJson(transactionStatusRequest); String requestJson = helper.convertObjectToJson(transactionStatusRequest);
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId, transactionStatusRequest.getMid(), clientReqId); LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId,
transactionStatusRequest.getMid(), clientReqId);
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId); Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
if (paymentInitiate.isEmpty()) { if (paymentInitiate.isEmpty()) {
throw new CustomException(BBPSConstant.NO_BILL_FOUND); throw new CustomException(BBPSConstant.NO_BILL_FOUND);
} }
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL + paymentInitiate.get().getTxnId(); String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL
+ paymentInitiate.get().getTxnId();
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID); BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
HttpHeaders headers = helper.buildHeaders(headersData); HttpHeaders headers = helper.buildHeaders(headersData);
InboundTraceLog inboundLog = helper.createInboundLog( InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
requestId, txnID, apiName, transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson); transactionStatusRequest.getMid(), BBPSConstant.HTTP_POST, requestJson);
LOGGER.debug("Inbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID); LOGGER.debug("Inbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
OutboundTraceLog outboundLog = helper.createOutboundLog( OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET,
txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null); null);
LOGGER.debug("Outbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID); LOGGER.debug("Outbound log created for clientReqId check | reqId={} | txnId={}", requestId, txnID);
try { try {
@@ -352,38 +366,33 @@ public class PaymentServiceImpl implements PaymentService {
helper.updateOutboundLogResponse(outboundLog, responseData); helper.updateOutboundLogResponse(outboundLog, responseData);
LOGGER.debug("Outbound log response updated for clientReqId check | reqId={} | txnId={}", requestId, txnID); LOGGER.debug("Outbound log response updated for clientReqId check | reqId={} | txnId={}", requestId, txnID);
Map<String, Object> dataMap = objectMapper.readValue( Map<String, Object> dataMap = objectMapper.readValue(responseData,
responseData, new TypeReference<Map<String, Object>>() {}); new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) { if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE); helper.updateInboundLogFailure(inboundLog, responseData, BBPSConstant.INVALID_RESPONSE);
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}", LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}", clientReqId,
clientReqId, responseData); responseData);
throw new CustomException( throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
String.valueOf(dataMap.get("message")),
String.valueOf(dataMap.get("status")),
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
String.valueOf(dataMap.get("remarks")) String.valueOf(dataMap.get("remarks")));
);
} }
TransactionStatusResponse responseWrapper = TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
objectMapper.convertValue(dataMap, TransactionStatusResponse.class); TransactionStatusResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp(); GeneralResp generalResp = responseWrapper.getGeneralResp();
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus()); LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus()); helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | clientReqId={} | status={}", apiName, requestId, clientReqId, generalResp.getStatus()); LOGGER.info("[{}] END | reqId={} | clientReqId={} | status={}", apiName, requestId, clientReqId,
return new ResponseModel( generalResp.getStatus());
generalResp.getMessage(), return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
Integer.parseInt(generalResp.getStatusCode()),
responseWrapper
);
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e); LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
@@ -393,7 +402,4 @@ public class PaymentServiceImpl implements PaymentService {
} }
} }
} }
@@ -4,7 +4,9 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.stereotype.Service; 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.ResponseModel;
import com.billpaymentservice.bbps.dto.TransactionHistoryMasterDTO; import com.billpaymentservice.bbps.dto.TransactionHistoryMasterDTO;
import com.billpaymentservice.bbps.dto.TransactionHistoryParticularDetailsDTO; import com.billpaymentservice.bbps.dto.TransactionHistoryParticularDetailsDTO;
@@ -57,22 +59,34 @@ public class TxnHistoryServiceImpl implements TxnHistoryService {
BBPSConstant.HTTP_GET, null); BBPSConstant.HTTP_GET, null);
try { 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()) { if (dataResult == null || dataResult.isEmpty()) {
log.info("[{}] Response Fetch From DB | reqId={} | data={}", apiName, requestId, dataResult); log.info("[{}] Response Fetch From DB | reqId={} | data={}", apiName, requestId, dataResult);
throw new CustomException("No Transcation Found This Mid", "FAILED", BBPSConstant.BADREQUEST, null); 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,
log.info("[{}] Response Fetch From DB | reqId={} | data={}", apiName, requestId, responseData); dataResult.getTotalElements());
List<TransactionHistoryParticularDetailsDTO> responseDatas = dataResult.stream() List<TransactionHistoryParticularDetailsDTO> responseDatas = dataResult.stream()
.map(mapperHelper::billerRemainingDetails).collect(Collectors.toList()); .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()); BBPSConstant.HTTP_OK_INT, responseDatas, responseDatas.size());
} catch (CustomException e) { } catch (CustomException e) {
@@ -146,6 +146,7 @@ public class BBPSConstant {
public static final String NULL_DATA_FROM_DB = "NULL_DATA_FROM_DB"; public static final String NULL_DATA_FROM_DB = "NULL_DATA_FROM_DB";
public static final String NO_MASTER_FIELDS_FOUND = "No master fields found"; public static final String NO_MASTER_FIELDS_FOUND = "No master fields found";
public static final String ALL_MASTER_FIELDS_FETCH = "All master fields fetched successfully"; public static final String ALL_MASTER_FIELDS_FETCH = "All master fields fetched successfully";
public static final String ALL_HISTORY_FIELDS_FETCH = "All history fields fetched successfully";
public static final String ALL_COMPLAINT_FIELDS_FETCH = "All complaint fields fetched successfully"; public static final String ALL_COMPLAINT_FIELDS_FETCH = "All complaint fields fetched successfully";
public static final String SOMETHING_WENT_WRONG = "Something went wrong"; public static final String SOMETHING_WENT_WRONG = "Something went wrong";
public static final String USER_ID_IS_EMPTY = "User id is empty"; public static final String USER_ID_IS_EMPTY = "User id is empty";
@@ -155,8 +156,8 @@ public class BBPSConstant {
public static final long BILL_VALIDATE_DELAY_MS = 12000L; // used after initiate bill validate public static final long BILL_VALIDATE_DELAY_MS = 12000L; // used after initiate bill validate
public static final long PAYMENT_STATUS_DELAY_MS = 9000L; // used after initiate payment public static final long PAYMENT_STATUS_DELAY_MS = 9000L; // used after initiate payment
public static final String enckey = "zk52olsyr9fl95h50eus8bhtyhoo5lp7"; public static final String enckey = "g5c4lr0tgjjqhu0bfgmhjf26ab0z8ktk";
public static final String mid = "Test-By-Aditya-1001"; public static final String mid = "MIDBBPS001THA";
public static final String callbackurl = "https://checkout.solwio.in/PGPayU/payu/callback"; public static final String callbackurl = "https://11.godemo.in/BBPS/payment/callback/startPayment";
public static final String companyName = "techwork technology"; public static final String companyName = "testing.com";
} }
@@ -239,7 +239,8 @@ public class BillerMapperHelper {
return billerRepo.saveAll(entities); return billerRepo.saveAll(entities);
} }
public CustomerParamGroupsDTO saveCustomerParamGroups(CustomerParamGroupsDTO dtos, String requestId, String txnId) { public CustomerParamGroupsDTO saveCustomerParamGroups(CustomerParamGroupsDTO dtos, String requestId, String txnId,
String userId) {
if (dtos == null || dtos.getGroups() == null || dtos.getGroups().isEmpty()) { if (dtos == null || dtos.getGroups() == null || dtos.getGroups().isEmpty()) {
return new CustomerParamGroupsDTO(); // Return empty DTO if no groups exist return new CustomerParamGroupsDTO(); // Return empty DTO if no groups exist
} }
@@ -248,7 +249,9 @@ public class BillerMapperHelper {
// Loop through the top-level groups and save them (including nested groups) // Loop through the top-level groups and save them (including nested groups)
for (GroupDTO groupDTO : dtos.getGroups()) { for (GroupDTO groupDTO : dtos.getGroups()) {
CustomerParamGroupById entity = saveGroupWithChildren(groupDTO, null, requestId, txnId); // null is for root CustomerParamGroupById entity = saveGroupWithChildren(groupDTO, null, requestId, txnId, userId); // null is
// for
// root
// (no // (no
// parent group) // parent group)
entities.add(entity); // Add the saved entity to the list entities.add(entity); // Add the saved entity to the list
@@ -263,7 +266,7 @@ public class BillerMapperHelper {
} }
private CustomerParamGroupById saveGroupWithChildren(GroupDTO groupDTO, CustomerParamGroupById parentGroup, private CustomerParamGroupById saveGroupWithChildren(GroupDTO groupDTO, CustomerParamGroupById parentGroup,
String requestId, String txnId) { String requestId, String txnId, String userId) {
// Create a new entity for the group // Create a new entity for the group
CustomerParamGroupById groupEntity = new CustomerParamGroupById(); CustomerParamGroupById groupEntity = new CustomerParamGroupById();
@@ -273,6 +276,7 @@ public class BillerMapperHelper {
groupEntity.setParentGroup(parentGroup); // Link to the parent group (if exists) groupEntity.setParentGroup(parentGroup); // Link to the parent group (if exists)
groupEntity.setRequestId(requestId); groupEntity.setRequestId(requestId);
groupEntity.setTxnId(txnId); groupEntity.setTxnId(txnId);
groupEntity.setUserId(userId);
groupEntity.setCreateDateTime(new Date()); groupEntity.setCreateDateTime(new Date());
// Save group parameters (if any) // Save group parameters (if any)
if (groupDTO.getParams() != null && !groupDTO.getParams().isEmpty()) { if (groupDTO.getParams() != null && !groupDTO.getParams().isEmpty()) {
@@ -290,8 +294,8 @@ public class BillerMapperHelper {
if (groupDTO.getGroups() != null && !groupDTO.getGroups().isEmpty()) { if (groupDTO.getGroups() != null && !groupDTO.getGroups().isEmpty()) {
List<CustomerParamGroupById> childEntities = new ArrayList<>(); List<CustomerParamGroupById> childEntities = new ArrayList<>();
for (GroupDTO childGroupDTO : groupDTO.getGroups()) { for (GroupDTO childGroupDTO : groupDTO.getGroups()) {
CustomerParamGroupById childEntity = saveGroupWithChildren(childGroupDTO, groupEntity, requestId, CustomerParamGroupById childEntity = saveGroupWithChildren(childGroupDTO, groupEntity, requestId, txnId,
txnId); // Pass userId); // Pass
// current // current
// group // group
// as // as
@@ -346,7 +350,8 @@ public class BillerMapperHelper {
} }
// Method to save AmountOptionsResponse and AmountOption entities // Method to save AmountOptionsResponse and AmountOption entities
public String saveAmountOptionsResponse(AmountOptionsResponse responseWrapper, String requestId, String txnId) { public String saveAmountOptionsResponse(AmountOptionsResponse responseWrapper, String requestId, String txnId,
String userId) {
// Convert AmountOptionsResponseDTO to AmountOptionsResponse entity // Convert AmountOptionsResponseDTO to AmountOptionsResponse entity
if (responseWrapper == null) { if (responseWrapper == null) {
@@ -358,14 +363,10 @@ public class BillerMapperHelper {
// Map AmountOptionDTO list to AmountOptionDetails entities // Map AmountOptionDTO list to AmountOptionDetails entities
List<AmountOptionDetails> amountOptionDetailsList = mapAmountOptionDTOToEntity( List<AmountOptionDetails> amountOptionDetailsList = mapAmountOptionDTOToEntity(
responseWrapper.getAmountOptionDAOS(), requestId, txnId); responseWrapper.getAmountOptionDAOS(), requestId, txnId, userId);
// Set the mapped AmountOptionDetails list to AmountOptionByBillerId entity
entity.setAmountOptionDetails(amountOptionDetailsList); entity.setAmountOptionDetails(amountOptionDetailsList);
entity.setCreateDateTime(new Date()); entity.setCreateDateTime(new Date());
// Save AmountOptionByBillerId entity (this will also save related
// AmountOptionDetails entities)
amountOptionByBillerIdRepository.save(entity); // Saves the entity and cascades to AmountOptionDetails amountOptionByBillerIdRepository.save(entity); // Saves the entity and cascades to AmountOptionDetails
// Return success message // Return success message
@@ -373,7 +374,7 @@ public class BillerMapperHelper {
} }
private List<AmountOptionDetails> mapAmountOptionDTOToEntity(List<AmountOptionDTO> amountOptionDTOs, private List<AmountOptionDetails> mapAmountOptionDTOToEntity(List<AmountOptionDTO> amountOptionDTOs,
String requestId, String txnId) { String requestId, String txnId, String userId) {
// If the list is null or empty, return an empty list of entities // If the list is null or empty, return an empty list of entities
if (amountOptionDTOs == null || amountOptionDTOs.isEmpty()) { if (amountOptionDTOs == null || amountOptionDTOs.isEmpty()) {
@@ -397,13 +398,14 @@ public class BillerMapperHelper {
amountOptionDetails.setAmountOptionId(dto.getAmountOptionId()); amountOptionDetails.setAmountOptionId(dto.getAmountOptionId());
amountOptionDetails.setRequestId(requestId); amountOptionDetails.setRequestId(requestId);
amountOptionDetails.setTxnId(txnId); amountOptionDetails.setTxnId(txnId);
amountOptionDetails.setUserId(userId);
// Return the mapped AmountOptionDetails entity // Return the mapped AmountOptionDetails entity
return amountOptionDetails; return amountOptionDetails;
})).collect(Collectors.toList()); // Collect them into a list and return })).collect(Collectors.toList()); // Collect them into a list and return
} }
public PlanResponses savePlanResponse(PlanResponse planResponse, String reqId, String txnId) { public PlanResponses savePlanResponse(PlanResponse planResponse, String reqId, String txnId, String userId) {
PlanResponses response = new PlanResponses(); PlanResponses response = new PlanResponses();
response.setRequestId(reqId); response.setRequestId(reqId);
response.setPageNo(planResponse.getPageNo()); response.setPageNo(planResponse.getPageNo());
@@ -411,6 +413,7 @@ public class BillerMapperHelper {
response.setTotalElements(planResponse.getTotalElements()); response.setTotalElements(planResponse.getTotalElements());
response.setTotalPages(planResponse.getTotalPages()); response.setTotalPages(planResponse.getTotalPages());
response.setTxnId(txnId); response.setTxnId(txnId);
response.setUserId(userId);
response.setCreateDateTime(new Date()); response.setCreateDateTime(new Date());
PlansList plansList = new PlansList(); PlansList plansList = new PlansList();
@@ -472,7 +475,7 @@ public class BillerMapperHelper {
return planResponseRepository.save(response); return planResponseRepository.save(response);
} }
public String saveCategoryItems(List<String> categoryRespList, String requestId, String txnId) { public String saveCategoryItems(List<String> categoryRespList, String requestId, String txnId, String userId) {
int savedCount = 0; // To track how many items were saved int savedCount = 0; // To track how many items were saved
if (categoryRespList == null || categoryRespList.isEmpty()) { if (categoryRespList == null || categoryRespList.isEmpty()) {
@@ -485,13 +488,14 @@ public class BillerMapperHelper {
category.setRequestId(txnId); category.setRequestId(txnId);
category.setRequestId(requestId); category.setRequestId(requestId);
category.setCreateDateTime(new Date()); category.setCreateDateTime(new Date());
category.setUserId(userId);
categoryResponseListRepository.save(category); categoryResponseListRepository.save(category);
savedCount++; savedCount++;
} }
return savedCount + " items were successfully saved."; return savedCount + " items were successfully saved.";
} }
public String saveComplaintStatus(TicketCheckStatusResponse response, String reqId, String txnId) { public String saveComplaintStatus(TicketCheckStatusResponse response, String reqId, String txnId, String userId) {
if (response == null || response.getTicketDetails() == null) { if (response == null || response.getTicketDetails() == null) {
throw new CustomException("Invalid response received!", "FAILURE", 500, "Response Null"); throw new CustomException("Invalid response received!", "FAILURE", 500, "Response Null");
@@ -531,6 +535,7 @@ public class BillerMapperHelper {
entity.setNpciTicketStatus(dto.getNpciTicketStatus()); entity.setNpciTicketStatus(dto.getNpciTicketStatus());
entity.setCreatedTime(dto.getCreatedTime()); entity.setCreatedTime(dto.getCreatedTime());
entity.setCreateDateTime(new Date()); entity.setCreateDateTime(new Date());
entity.setUserId(userId);
try { try {
ComplainStatus saved = complaintStatusRepository.save(entity); ComplainStatus saved = complaintStatusRepository.save(entity);
@@ -541,7 +546,8 @@ public class BillerMapperHelper {
} }
} }
public String saveComplaintHistory(ComplaintHistoryStatusResponse responseWrapper, String reqId, String txnId) { public String saveComplaintHistory(ComplaintHistoryStatusResponse responseWrapper, String reqId, String txnId,
String userId) {
if (responseWrapper == null || responseWrapper.getTicketHistories() == null if (responseWrapper == null || responseWrapper.getTicketHistories() == null
|| responseWrapper.getTicketHistories().isEmpty()) { || responseWrapper.getTicketHistories().isEmpty()) {
return "No complaint history data found to save."; return "No complaint history data found to save.";
@@ -560,6 +566,7 @@ public class BillerMapperHelper {
entity.setReqId(reqId); entity.setReqId(reqId);
entity.setTxnId(txnId); entity.setTxnId(txnId);
entity.setCreateDateTime(new Date()); entity.setCreateDateTime(new Date());
entity.setUserId(userId);
complaintHistoryRepository.save(entity); complaintHistoryRepository.save(entity);
savedCount++; savedCount++;
@@ -656,7 +663,8 @@ public class BillerMapperHelper {
return finalJson; return finalJson;
} }
public String saveComplainStatusDetail(ViewComplainByIdResponse responseWrapper, String reqId, String txnId) { public String saveComplainStatusDetail(ViewComplainByIdResponse responseWrapper, String reqId, String txnId,
String userId) {
ModelMapper mapper = new ModelMapper(); ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
@@ -674,6 +682,7 @@ public class BillerMapperHelper {
entity.setPage(String.valueOf(responseWrapper.getPage())); entity.setPage(String.valueOf(responseWrapper.getPage()));
entity.setPageSize(String.valueOf(responseWrapper.getPageSize())); entity.setPageSize(String.valueOf(responseWrapper.getPageSize()));
entity.setCreateDateTime(new Date()); entity.setCreateDateTime(new Date());
entity.setUserId(userId);
} }
@@ -794,7 +803,7 @@ public class BillerMapperHelper {
} }
public String saveTicketDisoptionDetails(List<TicketDispositionsDTO> dispositionsList, String requestId, public String saveTicketDisoptionDetails(List<TicketDispositionsDTO> dispositionsList, String requestId,
String txnId) { String txnId, String userId) {
if (dispositionsList == null || dispositionsList.isEmpty()) { if (dispositionsList == null || dispositionsList.isEmpty()) {
return "No disposition data received."; return "No disposition data received.";
@@ -820,7 +829,7 @@ public class BillerMapperHelper {
entity.setCreateDateTime(new Date()); entity.setCreateDateTime(new Date());
entity.setTxnId(txnId); entity.setTxnId(txnId);
entity.setReqId(requestId); entity.setReqId(requestId);
entity.setUserId(userId);
ticketDispositionRepository.save(entity); ticketDispositionRepository.save(entity);
savedCount++; savedCount++;
} }
@@ -833,7 +842,8 @@ public class BillerMapperHelper {
} }
} }
public String saveAllComplaints(ViewAllComplaintsTicketsResponse responseWrapper, String reqId, String txnId) { public String saveAllComplaints(ViewAllComplaintsTicketsResponse responseWrapper, String reqId, String txnId,
String userId) {
ModelMapper mapper = new ModelMapper(); ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT); mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
@@ -851,6 +861,7 @@ public class BillerMapperHelper {
entity.setTotalPages(String.valueOf(responseWrapper.getTotalPages())); entity.setTotalPages(String.valueOf(responseWrapper.getTotalPages()));
entity.setTotalElements(String.valueOf(responseWrapper.getTotalElements())); entity.setTotalElements(String.valueOf(responseWrapper.getTotalElements()));
entity.setCreateDateTime(new Date()); entity.setCreateDateTime(new Date());
entity.setUserId(userId);
} }
@@ -907,6 +918,7 @@ public class BillerMapperHelper {
billMaster.setUserId(responseWrapper.getUserId()); billMaster.setUserId(responseWrapper.getUserId());
billMaster.setReqId(billFetchByBillIdRequest.getReqId()); billMaster.setReqId(billFetchByBillIdRequest.getReqId());
billMaster.setTxnId(txnId); billMaster.setTxnId(txnId);
billMaster.setClientUserId(billFetchByBillIdRequest.getClientUserId());
// BILLER RESPONSE // BILLER RESPONSE
BillerResponse billerResponse = new BillerResponse(); BillerResponse billerResponse = new BillerResponse();
@@ -961,7 +973,8 @@ public class BillerMapperHelper {
billMasterRepository.save(billMaster); billMasterRepository.save(billMaster);
} }
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) { public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest,
String txnId) {
System.out.println("responseWrapper"); System.out.println("responseWrapper");
ModelMapper modelMapper = new ModelMapper(); ModelMapper modelMapper = new ModelMapper();
@@ -988,6 +1001,9 @@ public class BillerMapperHelper {
return ai; return ai;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
billEntity.setAdditionalInfo(additionalInfos); billEntity.setAdditionalInfo(additionalInfos);
billEntity.setClientUserId(billRequest.getClientUserId());
billEntity.setTxnId(txnId);
billEntity.setRefId(billRequest.getReqId());
} }
// ✅ Save everything (cascade handles child) // ✅ Save everything (cascade handles child)
@@ -1198,7 +1214,8 @@ public class BillerMapperHelper {
} }
} }
public String saveComplaintResponseEntity(ComplaintResponse responseWrapper, String requestId, String txnId,String userId) { public String saveComplaintResponseEntity(ComplaintResponse responseWrapper, String requestId, String txnId,
String userId) {
// 1. Convert ComplaintResponse DTO to ComplaintResponseEntity // 1. Convert ComplaintResponse DTO to ComplaintResponseEntity
ComplaintResponseEntity complaintResponseEntity = new ComplaintResponseEntity(); ComplaintResponseEntity complaintResponseEntity = new ComplaintResponseEntity();
@@ -3,7 +3,7 @@ package com.billpaymentservice.bbps.util;
import java.security.SecureRandom; import java.security.SecureRandom;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.Random;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -210,15 +210,20 @@ public class Helper {
} }
private String generateUniqueUserId() { private String generateUniqueUserId() {
String userId = UUID.randomUUID().toString(); // Generate UUID Random random = new Random();
// Generate a random 6-digit number (between 100000 and 999999)
String userId = String.format("USER%06d", random.nextInt(900000) + 100000); // Format as USER-XXXXXX
// Check if the userId already exists in the database (theoretically rare but // Check if the userId already exists in the database (theoretically rare but
// can happen) // can happen)
while (userRepository.existsByUserId(userId)) { while (userRepository.existsByUserId(userId)) {
// If it exists, generate a new one // If it exists, generate a new one
userId = UUID.randomUUID().toString(); userId = String.format("USER-%06d", random.nextInt(900000) + 100000); // Generate new 6-digit number with
// prefix
} }
return userId; return userId;
} }
} }
@@ -20,9 +20,9 @@ swagger.server.description=Local Development Server
# DataSource # DataSource
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
spring.datasource.username=postgres spring.datasource.username=postgres
#spring.datasource.password=UAT@DB_2025 spring.datasource.password=UAT@DB_2025
spring.datasource.password=himanshu@123 #spring.datasource.password=himanshu@123
spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.driver-class-name=org.postgresql.Driver
spring.datasource.type=com.zaxxer.hikari.HikariDataSource spring.datasource.type=com.zaxxer.hikari.HikariDataSource