10-11-25 after conflict

This commit is contained in:
Mohd-Arham
2025-11-10 11:56:29 +05:30
77 changed files with 1600 additions and 572 deletions
@@ -1,6 +1,9 @@
package com.billpaymentservice.bbps.util;
import com.billpaymentservice.bbps.entites.*;
import com.billpaymentservice.bbps.entites.BillerDetails;
import com.billpaymentservice.bbps.entites.BillerResponseParams;
import com.billpaymentservice.bbps.entites.InterchangeFee;
import com.billpaymentservice.bbps.entites.TransactionMaster;
public class EntityRelationshipUtil {
@@ -62,5 +65,29 @@ public class EntityRelationshipUtil {
}
}
}
public static void linkTransactionMasterRelationships(TransactionMaster entity) {
if (entity == null) return;
// ✅ DeviceBlockTag relationship link karna
if (entity.getDeviceBlockTags() != null) {
entity.getDeviceBlockTags().forEach(tag -> {
if (tag != null) {
tag.setTransactionMaster(entity);
}
});
}
// ✅ CustomerParamTransaction relationship link karna
if (entity.getCustomerParams() != null) {
entity.getCustomerParams().forEach(param -> {
if (param != null) {
param.setTransactionMaster(entity);
}
});
}
}
}
@@ -2,26 +2,36 @@ package com.billpaymentservice.bbps.util;
import java.security.SecureRandom;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.function.Function;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;
import com.billpaymentservice.bbps.dto.AdditionalInfoBillDTO;
import com.billpaymentservice.bbps.dto.CustomerParamDAO;
import com.billpaymentservice.bbps.dto.ResponseModel;
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
import com.billpaymentservice.bbps.entites.BBPSMastersData;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BBPSMasterDataRepo;
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
import com.billpaymentservice.bbps.entites.BillMaster;
import com.billpaymentservice.bbps.entites.BillerDetails;
import com.billpaymentservice.bbps.entites.BillerResponse;
import com.billpaymentservice.bbps.entites.CustomerParamBill;
import com.billpaymentservice.bbps.entites.InboundTraceLog;
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
import com.billpaymentservice.bbps.entites.PaymentChannel;
import com.billpaymentservice.bbps.entites.PaymentMode;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.MerchantRepository;
import com.billpaymentservice.bbps.repository.BBPSMasterDataRepo;
import com.billpaymentservice.bbps.repository.BillMasterRepository;
import com.billpaymentservice.bbps.repository.BillerDataRepository;
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@Component
@@ -36,13 +46,18 @@ public class Helper {
private final ObjectMapper objectMapper = new ObjectMapper();
private final BBPSMasterDataRepo bbpsMasterDataRepo;
private final BillerDataRepository billerDataRespository;
private final BillMasterRepository billMasterRepository;
// Constructor Injection
public Helper(BBPSMasterDataRepo bbpsMasterDataRepo, InboundTraceLogRepository inboundTraceLogRepository,
OutboundTraceLogRepository outboundTraceLogRepository) {
OutboundTraceLogRepository outboundTraceLogRepository,BillerDataRepository billerDataRepository,
BillMasterRepository billMasterRepository) {
this.bbpsMasterDataRepo = bbpsMasterDataRepo;
this.inboundTraceLogRepository = inboundTraceLogRepository;
this.outboundTraceLogRepository = outboundTraceLogRepository;
this.billerDataRespository=billerDataRepository;
this.billMasterRepository=billMasterRepository;
}
/**
@@ -182,7 +197,110 @@ public class Helper {
outboundLog.setResponseReceiveTime(LocalDateTime.now());
outboundTraceLogRepository.save(outboundLog);
}
/* ---------- End helpers ---------- */
public void saveOrUpdateBillerData(BillerDetails newEntity) {
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
if (existingOpt.isPresent()) {
BillerDetails existing = existingOpt.get();
// Update base biller fields
existing.setBillerName(newEntity.getBillerName());
existing.setBillerAliasName(newEntity.getBillerAliasName());
existing.setBillerDescription(newEntity.getBillerDescription());
existing.setStatus(newEntity.getStatus());
existing.setBillerCoverage(newEntity.getBillerCoverage());
// ... (update other simple fields as needed)
// ✅ Clear and replace nested lists to avoid duplicate inserts
existing.getBillerPaymentModes().clear();
if (newEntity.getBillerPaymentModes() != null) {
for (PaymentMode mode : newEntity.getBillerPaymentModes()) {
mode.setBiller(existing);
existing.getBillerPaymentModes().add(mode);
}
}
existing.getBillerPaymentChannels().clear();
if (newEntity.getBillerPaymentChannels() != null) {
for (PaymentChannel channel : newEntity.getBillerPaymentChannels()) {
channel.setBiller(existing);
existing.getBillerPaymentChannels().add(channel);
}
}
billerDataRespository.save(existing);
}
else {
// brand new biller
billerDataRespository.save(newEntity);
}
}
public void saveOrUpdateBillerData(BillDataResponse responseWrapper,
BillFetchByBillIdRequest billFetchByBillIdRequest) {
BillMaster billMaster =new BillMaster();
billMaster.setBillId("12333333hjsdfjsfdj");
billMaster.setRefId(responseWrapper.getRefId());
billMaster.setBillerId(responseWrapper.getBillerId());
billMaster.setStatus(responseWrapper.getStatus());
billMaster.setActionType(responseWrapper.getActionType());
billMaster.setUserId(responseWrapper.getUserId());
billMaster.setReqId(billFetchByBillIdRequest.getReqId()); // if available from your API request
billMaster.setTxnId("jhnjhbhj"); // give it from method
// ---- BILLER RESPONSE ----
BillerResponse billerResponse = new BillerResponse();
if (responseWrapper.getBillerResponse() != null) {
billerResponse.setBillId(responseWrapper.getBillerResponse().getBillId());
billerResponse.setAmount(responseWrapper.getBillerResponse().getAmount());
billerResponse.setBillDate(responseWrapper.getBillerResponse().getBillDate());
billerResponse.setBillNumber(responseWrapper.getBillerResponse().getBillNumber());
billerResponse.setBillPeriod(responseWrapper.getBillerResponse().getBillPeriod());
billerResponse.setCustConvFee(responseWrapper.getBillerResponse().getCustConvFee());
billerResponse.setCouCustConvFee(responseWrapper.getBillerResponse().getCouCustConvFee());
billerResponse.setDueDate(responseWrapper.getBillerResponse().getDueDate());
billerResponse.setCustomerName(responseWrapper.getBillerResponse().getCustomerName());
billerResponse.setAmountOption(responseWrapper.getBillerResponse().isAmountOption());
billerResponse.setBillMaster(billMaster); // maintain mapping
}
billMaster.setBillerResponse(billerResponse);
// ---- ADDITIONAL INFO ----
List<AdditionalInfoBill> additionalInfos = new ArrayList<>();
if (responseWrapper.getAdditionalInfo() != null) {
for (AdditionalInfoBillDTO info : responseWrapper.getAdditionalInfo()) {
AdditionalInfoBill entity = new AdditionalInfoBill();
entity.setName(info.getName());
entity.setValue(info.getValue());
entity.setBillMaster(billMaster); // maintain mapping
additionalInfos.add(entity);
}
}
billMaster.setAdditionalInfo(additionalInfos);
// ---- CUSTOMER PARAMS ----
List<CustomerParamBill> customerParams = new ArrayList<>();
if (responseWrapper.getCustomerParams() != null) {
for (CustomerParamDAO param : responseWrapper.getCustomerParams()) {
CustomerParamBill entity = new CustomerParamBill();
entity.setName(param.getName());
entity.setValue(param.getValue());
entity.setType(param.getType());
entity.setBillMaster(billMaster);
customerParams.add(entity);
}
}
billMaster.setCustomerParams(customerParams);
// ---- DATES ----
billMaster.setCreationDate(responseWrapper.getCreationDate());
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
billMasterRepository.save(billMaster);
}
}