update code

This commit is contained in:
Mohd-Arham
2025-11-25 12:19:17 +05:30
parent d0c2c1b363
commit de92de7f7d
4 changed files with 205 additions and 434 deletions
@@ -33,8 +33,10 @@ import com.billpaymentservice.bbps.dto.TicketDetailsDTO;
import com.billpaymentservice.bbps.dto.TicketDispositionsDTO;
import com.billpaymentservice.bbps.dto.request.BillFetchByBillIdRequest;
import com.billpaymentservice.bbps.dto.request.BillPaymentRequest;
import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
import com.billpaymentservice.bbps.dto.request.FetchBillRequest;
import com.billpaymentservice.bbps.dto.request.FetchBillValidatestRequest;
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
import com.billpaymentservice.bbps.dto.response.AmountOptionsResponse;
import com.billpaymentservice.bbps.dto.response.BillDataResponse;
import com.billpaymentservice.bbps.dto.response.ClientReqIdResponse;
@@ -48,6 +50,8 @@ import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
import com.billpaymentservice.bbps.dto.sentRequest.BillPaymentForwardRequest;
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillForwardRequest;
import com.billpaymentservice.bbps.dto.sentRequest.FetchBillValidatestForwardRequest;
import com.billpaymentservice.bbps.dto.sentRequest.FetchComplaintForwardRequest;
import com.billpaymentservice.bbps.dto.sentRequest.FetchTicketLatestStatusRequest;
import com.billpaymentservice.bbps.entites.AdditionalInfoBill;
import com.billpaymentservice.bbps.entites.AdditionalInfoBillValidate;
import com.billpaymentservice.bbps.entites.AdditionalInfoPlans;
@@ -137,10 +141,8 @@ public class BillerMapperHelper {
CheckClientBillerDataRepository checkClientBillerDataRepository,
TicketDispositionRepository ticketDispositionRepository,
ViewAllComplainTicketDetailRepository viewAllComplainTicketDetailRepository,
ContactMasterDataRepository contactMasterDataRepository,
BBPSMasterDataRepo bbpsMasterDataRepo,
BillerDataRepository billerDataRespository,
BillMasterRepository billMasterRepository,
ContactMasterDataRepository contactMasterDataRepository, BBPSMasterDataRepo bbpsMasterDataRepo,
BillerDataRepository billerDataRespository, BillMasterRepository billMasterRepository,
BillValidationRepository billValidationRepository) {
this.billerRepo = billerRepo;
this.customerParamGroupByBillerIdRepo = customerParamGroupByBillerIdRepo;
@@ -860,196 +862,202 @@ public class BillerMapperHelper {
public void saveOrUpdateBillerData(BillerDetails newEntity) {
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
Optional<BillerDetails> existingOpt = billerDataRespository.findByBillerId(newEntity.getBillerId());
if (existingOpt.isPresent()) {
//logic to be written
}
else {
// brand new biller
billerDataRespository.save(newEntity);
}
if (existingOpt.isPresent()) {
// logic to be written
} else {
// brand new biller
billerDataRespository.save(newEntity);
}
}
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
BillFetchByBillIdRequest billFetchByBillIdRequest,String txnId) {
public void saveOrUpdateBillData(BillDataResponse responseWrapper,
BillFetchByBillIdRequest billFetchByBillIdRequest, String txnId) {
BillMaster billMaster = new BillMaster();
BillMaster billMaster = new BillMaster();
billMaster.setBillId(responseWrapper.getBillId());
billMaster.setRefId(responseWrapper.getRefId());
billMaster.setBillerId(responseWrapper.getBillerId());
billMaster.setStatus(responseWrapper.getStatus());
billMaster.setActionType(responseWrapper.getActionType());
billMaster.setUserId(responseWrapper.getUserId());
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
billMaster.setTxnId(txnId);
billMaster.setBillId(responseWrapper.getBillId());
billMaster.setRefId(responseWrapper.getRefId());
billMaster.setBillerId(responseWrapper.getBillerId());
billMaster.setStatus(responseWrapper.getStatus());
billMaster.setActionType(responseWrapper.getActionType());
billMaster.setUserId(responseWrapper.getUserId());
billMaster.setReqId(billFetchByBillIdRequest.getReqId());
billMaster.setTxnId(txnId);
// 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);
}
billMaster.setBillerResponse(billerResponse);
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);
}
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);
additionalInfos.add(entity);
}
}
billMaster.setAdditionalInfo(additionalInfos);
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);
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() == null ? "" : param.getValue());
entity.setType(param.getType() == null ? "" : param.getType());
entity.setBillMaster(billMaster);
customerParams.add(entity);
}
}
billMaster.setCustomerParams(customerParams);
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() == null ? "" : param.getValue());
entity.setType(param.getType() == null ? "" : 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());
billMaster.setCreationDate(responseWrapper.getCreationDate());
billMaster.setModifiedDate(responseWrapper.getModifiedDate());
billMaster.setCreatedEpochDate(responseWrapper.getCreatedEpochDate());
billMaster.setModifiedEpochDate(responseWrapper.getModifiedEpochDate());
billMasterRepository.save(billMaster);
}
billMasterRepository.save(billMaster);
}
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) {
System.out.println("responseWrapper");
ModelMapper modelMapper = new ModelMapper();
try {
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
// ✅ Map the main object
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
// ✅ Manually handle only the nested relationship part
if (responseWrapper.getCustomerParams() != null) {
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams()
.stream()
.map(param -> {
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
cp.setBill(billEntity); // maintain relation
return cp;
})
.collect(Collectors.toList());
billEntity.setCustomerParams(customerParams);
}
if (responseWrapper.getAdditionalInfo() != null) {
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo()
.stream()
.map(info -> {
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
ai.setBill(billEntity); // maintain relation
return ai;
})
.collect(Collectors.toList());
billEntity.setAdditionalInfo(additionalInfos);
}
// ✅ Save everything (cascade handles child)
billValidationRepository.save(billEntity);
LOGGER.info("Bill validation saved successfully for billId={}", billEntity.getBillId());
} catch (Exception ex) {
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
throw new RuntimeException("Failed to save bill validation data", ex);
}
}
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
FetchBillForwardRequest forward = new FetchBillForwardRequest();
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setClientReqId(req.getClientReqId());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setRemitterName(req.getRemitterName());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
forward.setRemitterIdentity(req.getRemitterIdentity());
return forward;
}
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setClientReqId(req.getClientReqId());
forward.setMacAddress(req.getMacAddress());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
return forward;
}
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
forward.setTenantId(req.getTenantId());
forward.setRefId(req.getRefId());
forward.setBillId(req.getBillId());
forward.setAmountOptions(req.isAmountOptions());
forward.setPaymentMode(req.getPaymentMode());
forward.setPaymentInformation(req.getPaymentInformation());
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setTxnAmount(req.getTxnAmount());
forward.setPaymentRefId(req.getPaymentRefId());
forward.setClientReqId(req.getClientReqId());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
forward.setRemitterIdentity(req.getRemitterIdentity());
forward.setAmountBreakSet(req.getAmountBreakSet());
return forward;
}
public void saveBillValidation(FetchBillValidateResponse responseWrapper, BillFetchByBillIdRequest billRequest) {
System.out.println("responseWrapper");
ModelMapper modelMapper = new ModelMapper();
try {
LOGGER.info("Saving bill validation data for billId={}", responseWrapper.getBillId());
// ✅ Map the main object
BillValidation billEntity = modelMapper.map(responseWrapper, BillValidation.class);
// ✅ Manually handle only the nested relationship part
if (responseWrapper.getCustomerParams() != null) {
List<CustomerParamBillValidation> customerParams = responseWrapper.getCustomerParams().stream()
.map(param -> {
CustomerParamBillValidation cp = modelMapper.map(param, CustomerParamBillValidation.class);
cp.setBill(billEntity); // maintain relation
return cp;
}).collect(Collectors.toList());
billEntity.setCustomerParams(customerParams);
}
if (responseWrapper.getAdditionalInfo() != null) {
List<AdditionalInfoBillValidate> additionalInfos = responseWrapper.getAdditionalInfo().stream()
.map(info -> {
AdditionalInfoBillValidate ai = modelMapper.map(info, AdditionalInfoBillValidate.class);
ai.setBill(billEntity); // maintain relation
return ai;
}).collect(Collectors.toList());
billEntity.setAdditionalInfo(additionalInfos);
}
// ✅ Save everything (cascade handles child)
billValidationRepository.save(billEntity);
LOGGER.info("Bill validation saved successfully for billId={}", billEntity.getBillId());
} catch (Exception ex) {
LOGGER.error("Error saving BillValidation data: {}", ex.getMessage(), ex);
throw new RuntimeException("Failed to save bill validation data", ex);
}
}
public FetchBillForwardRequest fetchBillForwardRequestMap(FetchBillRequest req) {
FetchBillForwardRequest forward = new FetchBillForwardRequest();
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setClientReqId(req.getClientReqId());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setRemitterName(req.getRemitterName());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
forward.setRemitterIdentity(req.getRemitterIdentity());
return forward;
}
public FetchBillValidatestForwardRequest fetchBillValidatestForwardRequest(FetchBillValidatestRequest req) {
FetchBillValidatestForwardRequest forward = new FetchBillValidatestForwardRequest();
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setClientReqId(req.getClientReqId());
forward.setMacAddress(req.getMacAddress());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
return forward;
}
public BillPaymentForwardRequest billPaymentForwardRequest(BillPaymentRequest req) {
BillPaymentForwardRequest forward = new BillPaymentForwardRequest();
forward.setTenantId(req.getTenantId());
forward.setRefId(req.getRefId());
forward.setBillId(req.getBillId());
forward.setAmountOptions(req.isAmountOptions());
forward.setPaymentMode(req.getPaymentMode());
forward.setPaymentInformation(req.getPaymentInformation());
forward.setBillerId(req.getBillerId());
forward.setBillerName(req.getBillerName());
forward.setBillerCategory(req.getBillerCategory());
forward.setMacAdress(req.getMacAdress());
forward.setCustomerMobNo(req.getCustomerMobNo());
forward.setTxnAmount(req.getTxnAmount());
forward.setPaymentRefId(req.getPaymentRefId());
forward.setClientReqId(req.getClientReqId());
forward.setPaymentChannel(req.getPaymentChannel());
forward.setDeviceBlockTags(req.getDeviceBlockTags());
forward.setCustomerParamsRequest(req.getCustomerParamsRequest());
forward.setRemitterIdentity(req.getRemitterIdentity());
forward.setAmountBreakSet(req.getAmountBreakSet());
return forward;
}
public FetchComplaintForwardRequest fetchComplaintForwardRequestMap(ComplaintRequestDTO complainRequestDTO) {
FetchComplaintForwardRequest forward = new FetchComplaintForwardRequest();
forward.setBillerId(complainRequestDTO.getBillerId());
forward.setBillerName(complainRequestDTO.getBillerName());
forward.setTicketDescription(complainRequestDTO.getTicketDescription());
forward.setTicketDisposition(complainRequestDTO.getTicketDisposition());
forward.setTicketDispositionCode(complainRequestDTO.getTicketDispositionCode());
forward.setTxnId(complainRequestDTO.getTxnId());
return forward;
}
public FetchTicketLatestStatusRequest fetchTicketLatestStatusRequestMap(GetTicketLatestStausRequest request) {
FetchTicketLatestStatusRequest forward = new FetchTicketLatestStatusRequest();
forward.setTicketId(request.getTicketId());
forward.setTxnNpciId(request.getTxnNpciId());
return forward;
}
}