add code history
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
package com.billpaymentservice.bbps.controller;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.PaymentHistoryRequest;
|
||||
import com.billpaymentservice.bbps.service.TxnHistoryService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/history")
|
||||
@CrossOrigin(origins = "*")
|
||||
@Slf4j
|
||||
public class TxnHistoryController {
|
||||
|
||||
private final TxnHistoryService txnHistory;
|
||||
|
||||
public TxnHistoryController(TxnHistoryService txnHistory) {
|
||||
this.txnHistory = txnHistory;
|
||||
|
||||
}
|
||||
|
||||
@PostMapping(value = "/paymentHistoryDetails", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public ResponseEntity<ResponseModel> getPaymentHistory(
|
||||
@Validated @RequestBody PaymentHistoryRequest paymentHistoryRequest) {
|
||||
|
||||
ResponseModel response = txnHistory.getPaymentHostoryDetails(paymentHistoryRequest);
|
||||
return ResponseEntity.ok(response);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.billpaymentservice.bbps.dto;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@ToString
|
||||
public class TransactionHistoryMasterDTO {
|
||||
|
||||
private String bankTxnId;
|
||||
private String txnId;
|
||||
private String clientUserId;
|
||||
private String mid;
|
||||
private String reqId;
|
||||
private String refId;
|
||||
private String txnNpciId;
|
||||
private String paymentRefId;
|
||||
private String remitterName;
|
||||
private String orderId;
|
||||
private String billId;
|
||||
private String userType;
|
||||
private String userId;
|
||||
private Double txnAmount;
|
||||
private Double totalTxnAmount;
|
||||
private String billerId;
|
||||
private String billerCategory;
|
||||
private String billerName;
|
||||
private String clientReqId;
|
||||
private String offUsPay;
|
||||
private String splitPay;
|
||||
private String quickPay;
|
||||
private String paymentMode;
|
||||
private String agentPaymentInformation;
|
||||
private Double custConvFee;
|
||||
private String currency;
|
||||
private String status;
|
||||
private String requestedIp;
|
||||
private String customerMobNo;
|
||||
private String macAddress;
|
||||
private Double splitPayAmount;
|
||||
private Double couCustConvFee;
|
||||
private Boolean settlementVerification;
|
||||
private String fundTxnType;
|
||||
private String reason;
|
||||
private String amountTags;
|
||||
private String paymentInformation;
|
||||
private String planId;
|
||||
private String planType;
|
||||
private String creationDate;
|
||||
private String modifiedDate;
|
||||
private Long createdEpochDate;
|
||||
private Long modifiedEpochDate;
|
||||
|
||||
}
|
||||
@@ -30,7 +30,6 @@ public abstract class BaseClass {
|
||||
@NotBlank(message = "Request ID cannot be null or blank")
|
||||
private String reqId;
|
||||
|
||||
@JsonProperty("userId")
|
||||
private String clientUserId;
|
||||
|
||||
private DeviceDetail deviceDetial;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.billpaymentservice.bbps.dto.request;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class PaymentHistoryRequest extends BaseClass {
|
||||
|
||||
}
|
||||
@@ -1,9 +1,17 @@
|
||||
package com.billpaymentservice.bbps.repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
|
||||
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
||||
|
||||
public interface TransactionMasterRepository extends JpaRepository<TransactionMaster, String> {
|
||||
|
||||
@Query("SELECT t FROM TransactionMaster t WHERE t.mid = :mid OR t.clientUserId = :clientUserId")
|
||||
List<TransactionMaster> findByMidOrClientUserId(@Param("mid") String mid,
|
||||
@Param("clientUserId") String clientUserId);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.billpaymentservice.bbps.service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.request.PaymentHistoryRequest;
|
||||
|
||||
public interface TxnHistoryService {
|
||||
|
||||
ResponseModel getPaymentHostoryDetails(PaymentHistoryRequest paymentHistoryRequest);
|
||||
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import com.billpaymentservice.bbps.entites.UsersDetails;
|
||||
import com.billpaymentservice.bbps.repository.UserRepository;
|
||||
import com.billpaymentservice.bbps.repository.UsersDetailsRepository;
|
||||
import com.billpaymentservice.bbps.service.AuthService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
import com.billpaymentservice.bbps.util.OtpClient;
|
||||
import java.util.Optional;
|
||||
@@ -93,8 +94,13 @@ public class AuthServiceImpl implements AuthService {
|
||||
return ResponseModel.builder().message("Login Success").status("Success").statusCode(200).data(authResp)
|
||||
.build();
|
||||
} else {
|
||||
AuthResponses authResp = new AuthResponses("", "User Not Found", "Authentication failed", 401, null);
|
||||
return ResponseModel.builder().message("User Not Found").status("Failure").statusCode(401)
|
||||
LOGGER.warn("OTP verified successfully, but user not found for mobileNo: {}", mobileNo);
|
||||
// AuthResponses authResp = new AuthResponses("", "User Not Found", "Authentication failed", 401, null);
|
||||
AuthResponses authResp = new AuthResponses("", "User Not Found",
|
||||
"OTP verified successfully, but user not found", BBPSConstant.OTP_VERIFIED_USER_NOT_FORUN,
|
||||
null);
|
||||
return ResponseModel.builder().message("OTP verified successfully, but user not found")
|
||||
.status("Failure").statusCode(BBPSConstant.OTP_VERIFIED_USER_NOT_FORUN) // Not Found
|
||||
.data(authResp).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.billpaymentservice.bbps.serviceImpl;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.ResponseModel;
|
||||
import com.billpaymentservice.bbps.dto.TransactionHistoryMasterDTO;
|
||||
import com.billpaymentservice.bbps.dto.request.PaymentHistoryRequest;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
||||
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.TransactionMasterRepository;
|
||||
import com.billpaymentservice.bbps.service.TxnHistoryService;
|
||||
import com.billpaymentservice.bbps.util.BBPSConstant;
|
||||
import com.billpaymentservice.bbps.util.BillerMapperHelper;
|
||||
import com.billpaymentservice.bbps.util.Helper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class TxnHistoryServiceImpl implements TxnHistoryService {
|
||||
|
||||
private final Helper helper;
|
||||
private final BillerMapperHelper mapperHelper;
|
||||
private final TransactionMasterRepository transactionMasterRepository;
|
||||
|
||||
public TxnHistoryServiceImpl(Helper helper, BillerMapperHelper mapperHelper,
|
||||
TransactionMasterRepository transactionMasterRepository) {
|
||||
this.helper = helper;
|
||||
this.mapperHelper = mapperHelper;
|
||||
this.transactionMasterRepository = transactionMasterRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel getPaymentHostoryDetails(PaymentHistoryRequest paymentHistoryRequest) {
|
||||
|
||||
String apiName = BBPSConstant.GET_PAYMENT_HISTORY;
|
||||
String requestId = paymentHistoryRequest.getReqId();
|
||||
String mid = paymentHistoryRequest.getMid();
|
||||
String clientUserId = paymentHistoryRequest.getClientUserId();
|
||||
log.info("[{}] START | reqId={} | mid={} | userId={}", apiName, requestId, mid, clientUserId);
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = "this api fetch data from DB not BBPS url !";
|
||||
log.info("[{}] Full URL={}", apiName, fullUrl);
|
||||
String requestJson = helper.convertObjectToJson(paymentHistoryRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, mid, BBPSConstant.HTTP_GET,
|
||||
requestJson);
|
||||
helper.validateMerchant(mid);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl,
|
||||
BBPSConstant.HTTP_GET, null);
|
||||
|
||||
try {
|
||||
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);
|
||||
|
||||
List<TransactionHistoryMasterDTO> responseDatas = dataResult.stream().map(mapperHelper::toDTO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, String.valueOf(responseData));
|
||||
|
||||
return new ResponseModel(BBPSConstant.ALL_MASTER_FIELDS_FETCH, BBPSConstant.SUCCESS_RESPONSE,
|
||||
BBPSConstant.HTTP_OK_INT, responseDatas, responseDatas.size());
|
||||
|
||||
} catch (CustomException e) {
|
||||
// Log and rethrow the custom exception
|
||||
log.error("[{}] CustomException occurred: {}", apiName, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.NO_BILL_FOUND);
|
||||
throw e; // Propagate the exact CustomException
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("JSON Parsing Error: {}", e.getMessage());
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@ public class BBPSConstant {
|
||||
public static final Long SENT_TO_PROCESSOR_CODE = 198L;
|
||||
public static final Long SUCCESS_CODE = 200L;
|
||||
public static final Long FAILED_CODE = 99L;
|
||||
public static final int OTP_VERIFIED_USER_NOT_FORUN =601;
|
||||
public static final Long SCHEDULER_CODE = 222L;
|
||||
public static final Long PENDING_CODE = 211L;
|
||||
public static final Long FRAUD_CODE = 1001L;
|
||||
@@ -104,6 +105,7 @@ public class BBPSConstant {
|
||||
public static final String API_FETCH_INITIATING_CHANNEL = "FetchInitiatingChannel";
|
||||
public static final String API_FETCH_PLAN_BY_CATEGORIES = "FetchPlanByCategories";
|
||||
public static final String API_GET_TICKET_DISPOSITIONS = "GetTicketDispositionDetails";
|
||||
public static final String GET_PAYMENT_HISTORY = "GET_PAYMENT_HISTORY";
|
||||
|
||||
// Payment related API names
|
||||
public static final String API_INITIATE_PAYMENT = "InitiatePayment";
|
||||
|
||||
@@ -31,6 +31,7 @@ import com.billpaymentservice.bbps.dto.MasterCategoryBillerResponse;
|
||||
import com.billpaymentservice.bbps.dto.PlanDTO;
|
||||
import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
|
||||
import com.billpaymentservice.bbps.dto.TicketDispositionsDTO;
|
||||
import com.billpaymentservice.bbps.dto.TransactionHistoryMasterDTO;
|
||||
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
||||
@@ -82,6 +83,7 @@ import com.billpaymentservice.bbps.entites.PlanCategorySubType;
|
||||
import com.billpaymentservice.bbps.entites.PlanResponses;
|
||||
import com.billpaymentservice.bbps.entites.PlansList;
|
||||
import com.billpaymentservice.bbps.entites.TicketDispositionDetails;
|
||||
import com.billpaymentservice.bbps.entites.TransactionMaster;
|
||||
import com.billpaymentservice.bbps.entites.ViewAllComplaintTicketStatusDetails;
|
||||
import com.billpaymentservice.bbps.exception.CustomException;
|
||||
import com.billpaymentservice.bbps.repository.AmountOptionByBillerIdRepository;
|
||||
@@ -1057,4 +1059,54 @@ public class BillerMapperHelper {
|
||||
forward.setTxnNpciId(request.getTxnNpciId());
|
||||
return forward;
|
||||
}
|
||||
|
||||
public TransactionHistoryMasterDTO toDTO(TransactionMaster transactionMaster) {
|
||||
if (transactionMaster == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a new DTO and set the values from the entity
|
||||
TransactionHistoryMasterDTO dto = new TransactionHistoryMasterDTO();
|
||||
dto.setBankTxnId(transactionMaster.getBankTxnId());
|
||||
dto.setTxnId(transactionMaster.getTxnId());
|
||||
dto.setMid(transactionMaster.getMid());
|
||||
dto.setReqId(transactionMaster.getReqId());
|
||||
dto.setBillerId(transactionMaster.getBillerId());
|
||||
dto.setTxnAmount(transactionMaster.getTxnAmount());
|
||||
dto.setStatus(transactionMaster.getStatus());
|
||||
dto.setRemitterName(transactionMaster.getRemitterName());
|
||||
dto.setOrderId(transactionMaster.getOrderId());
|
||||
dto.setBillId(transactionMaster.getBillId());
|
||||
dto.setUserType(transactionMaster.getUserType());
|
||||
dto.setUserId(transactionMaster.getUserId());
|
||||
dto.setTotalTxnAmount(transactionMaster.getTotalTxnAmount());
|
||||
dto.setBillerCategory(transactionMaster.getBillerCategory());
|
||||
dto.setBillerName(transactionMaster.getBillerName());
|
||||
dto.setClientReqId(transactionMaster.getClientReqId());
|
||||
dto.setOffUsPay(transactionMaster.getOffUsPay());
|
||||
dto.setSplitPay(transactionMaster.getSplitPay());
|
||||
dto.setQuickPay(transactionMaster.getQuickPay());
|
||||
dto.setPaymentMode(transactionMaster.getPaymentMode());
|
||||
dto.setAgentPaymentInformation(transactionMaster.getAgentPaymentInformation());
|
||||
dto.setCustConvFee(transactionMaster.getCustConvFee());
|
||||
dto.setCurrency(transactionMaster.getCurrency());
|
||||
dto.setRequestedIp(transactionMaster.getRequestedIp());
|
||||
dto.setCustomerMobNo(transactionMaster.getCustomerMobNo());
|
||||
dto.setMacAddress(transactionMaster.getMacAddress());
|
||||
dto.setSplitPayAmount(transactionMaster.getSplitPayAmount());
|
||||
dto.setCouCustConvFee(transactionMaster.getCouCustConvFee());
|
||||
dto.setSettlementVerification(transactionMaster.getSettlementVerification());
|
||||
dto.setFundTxnType(transactionMaster.getFundTxnType());
|
||||
dto.setReason(transactionMaster.getReason());
|
||||
dto.setAmountTags(transactionMaster.getAmountTags());
|
||||
dto.setPaymentInformation(transactionMaster.getPaymentInformation());
|
||||
dto.setPlanId(transactionMaster.getPlanId());
|
||||
dto.setPlanType(transactionMaster.getPlanType());
|
||||
dto.setCreationDate(transactionMaster.getCreationDate());
|
||||
dto.setModifiedDate(transactionMaster.getModifiedDate());
|
||||
dto.setCreatedEpochDate(transactionMaster.getCreatedEpochDate());
|
||||
dto.setModifiedEpochDate(transactionMaster.getModifiedEpochDate());
|
||||
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ swagger.server.description=Local Development Server
|
||||
# DataSource
|
||||
spring.datasource.url=jdbc:postgresql://localhost:5432/BBPS
|
||||
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.type=com.zaxxer.hikari.HikariDataSource
|
||||
|
||||
|
||||
Reference in New Issue
Block a user