Nabeel-DG-BS
Raja Nabeel 2 years ago
parent 7c46dbf603
commit 19ee585df7

@ -2,15 +2,20 @@ package com.mfsys.uco;
public interface UCOURI { public interface UCOURI {
String VIEW_BALANCE = "/user/viewBalance"; String VIEW_BALANCE = "/user/viewBalance";
String ONBOARD_CUSTOMER = "/user/onboardCutomer"; String ONBOARD_CUSTOMER = "/auth/user/authenticate/onboardCutomer";
String FETCH_DEPOSITACCOUNTS = "/depositAccounts"; String FETCH_DEPOSITACCOUNTS = "/depositAccounts";
String FETCH_ACCOUNT_STATEMENT = "/accountStatement"; String FETCH_ACCOUNT_STATEMENT = "/accountStatement";
String FETCH_ACCOUNT_INQUIRY = "/accountInquiry"; String FETCH_ACCOUNT_INQUIRY = "/accountInquiry";
String GET_TRANSACTION_PIN = "/transactionPin";
String SUBMIT_TRANSACTION = "/submitTransaction";
String GENERATE_TRANSACTIONS_REPORT = "/generateReport"; String GENERATE_TRANSACTIONS_REPORT = "/generateReport";
String CREATE_TRAN_PIN = "/createTransactionPin"; String CREATE_TRAN_PIN = "/createTransactionPin";
String VERIFY_TRAN_PIN = "/verifyTransactionPin"; String VERIFY_TRAN_PIN = "/verifyTransactionPin";
String CHANGE_TRAN_PIN = "/changeTransactionPin"; String CHANGE_TRAN_PIN = "/changeTransactionPin";
String FETCH_LOGIIN_DATA = "/fetchlogindata"; String FETCH_LOGIIN_DATA = "/fetchlogindata";
String FETCH_EXCHANGE_RATE = "/fetchExchangeRate";
String GET_DR_TRANSACTION_PIN = "/sendDrTranOtpAndVerifyTranPin";
String SUBMIT_DR_TRANSACTION = "/submitDrTransaction";
String SUBMIT_CR_TRANSACTION = "/submitCrTransaction";
String PENDING_CR_TRANSACTION = "/fetchPendingCredittransaction";
String BANKING_CASH_IN = "/deposit/transactions/uco/cash-in";
String BANKING_CASH_OUT = "/deposit/transactions/uco/cash-out";
} }

@ -1,5 +1,6 @@
package com.mfsys.uco.config; package com.mfsys.uco.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -8,6 +9,9 @@ import org.springframework.web.reactive.function.client.WebClient;
@Configuration @Configuration
public class WebClientconfiguration { public class WebClientconfiguration {
@Value("${base.ciihive}")
private String ciihive;
@LoadBalanced @LoadBalanced
@Bean @Bean
public WebClient.Builder loadBalancedWebClientBuilder() { public WebClient.Builder loadBalancedWebClientBuilder() {
@ -17,11 +21,13 @@ public class WebClientconfiguration {
@Bean @Bean
public WebClient webClientDeposit() { public WebClient webClientDeposit() {
return WebClient.create("http://localhost:9095"); return WebClient.create("http://localhost:9095");
// return WebClient.create(ciihive);
} }
@Bean @Bean
public WebClient webClientCrm() { public WebClient webClientCrm() {
return WebClient.create("http://localhost:9096"); return WebClient.create(ciihive);
// return WebClient.create("http://localhost:9096");
} }
} }

@ -4,4 +4,6 @@ public interface UCOURI {
String GET_UCOACC_BALANCE = "/deposit/getUcoAccountBalance"; String GET_UCOACC_BALANCE = "/deposit/getUcoAccountBalance";
String CUSTOMER_ONBOARDING = "/crm/onboarding/digital/customer"; String CUSTOMER_ONBOARDING = "/crm/onboarding/digital/customer";
String GET_CMP_UCOACCOUNTS = "/deposit/getUcoAccounts"; String GET_CMP_UCOACCOUNTS = "/deposit/getUcoAccounts";
String FETCH_EXCHANGE_RATE = "/deposit/uco/fetchExchangeRate";
} }

@ -0,0 +1,48 @@
package com.mfsys.uco.controller;
import com.mfsys.comm.util.FunctionReturnDetail;
import com.mfsys.uco.UCOURI;
import com.mfsys.uco.dto.CashInTransactionRequest;
import com.mfsys.uco.dto.CashOutTransactionRequest;
import com.mfsys.uco.dto.Transaction.TransactionOtpRequestModel;
import com.mfsys.uco.dto.TransactionPinResponseModel;
import com.mfsys.uco.dto.webclientdto.AccountDetail;
import com.mfsys.uco.model.TransactionTrail;
import com.mfsys.uco.service.TransactionService;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequiredArgsConstructor
public class TransactionController {
private final TransactionService transactionService;
@PostMapping(UCOURI.GET_DR_TRANSACTION_PIN)
public TransactionPinResponseModel submitTransaction(@RequestBody TransactionOtpRequestModel transactionOtpRequestModel) {
return transactionService.sendOtpAndValidateTranPin(transactionOtpRequestModel);
}
@PostMapping(UCOURI.SUBMIT_DR_TRANSACTION)
public ResponseEntity<FunctionReturnDetail<String>> cashInTransaction(@RequestBody CashInTransactionRequest transactionRequest) {
transactionService.cashInTransaction(transactionRequest);
return null;
}
@PostMapping(UCOURI.SUBMIT_CR_TRANSACTION)
public ResponseEntity<FunctionReturnDetail<String>> cashOutTransaction(@RequestBody CashOutTransactionRequest transactionRequest) {
transactionService.cashOutTransaction(transactionRequest);
return null;
}
@GetMapping(UCOURI.PENDING_CR_TRANSACTION)
public List<TransactionTrail> getDepositAccounts(
@RequestParam String porOrgacode,
@RequestParam String mbmBkmsnumber) {
return transactionService.fetchPendingCrTransactions(porOrgacode, mbmBkmsnumber);
}
}

@ -24,6 +24,7 @@ import java.math.BigDecimal;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Base64; import java.util.Base64;
import java.util.List; import java.util.List;
import java.util.Map;
@RestController @RestController
@RequiredArgsConstructor @RequiredArgsConstructor
@ -34,11 +35,10 @@ public class UserController {
private final UcoAccountService ucoAccountService; private final UcoAccountService ucoAccountService;
private final CustomerProfileService customerProfileService; private final CustomerProfileService customerProfileService;
@PostMapping(UCOURI.ONBOARD_CUSTOMER) @PostMapping(UCOURI.ONBOARD_CUSTOMER)
public ResponseEntity<HttpStatus> customerOnBoarding(@RequestBody SignupStep3RequestModel signupStep3RequestModel) { public ResponseEntity<HttpStatus> customerOnBoarding(@RequestBody SignupStep3RequestModel signupStep3RequestModel) {
ucoAccountService.onBoardCustomer(signupStep3RequestModel); ucoAccountService.onBoardCustomer(signupStep3RequestModel);
return null; return ResponseEntity.ok(HttpStatus.OK);
} }
@PostMapping(UCOURI.VIEW_BALANCE) @PostMapping(UCOURI.VIEW_BALANCE)
@ -47,6 +47,7 @@ public class UserController {
viewBalanceResponseModel.setMbmBkmsbalance(ucoAccountService.fetchAccountBalance(viewBalanceRequestModel.getPorOrgacode(),viewBalanceRequestModel.getMbmBkmsNumber())); viewBalanceResponseModel.setMbmBkmsbalance(ucoAccountService.fetchAccountBalance(viewBalanceRequestModel.getPorOrgacode(),viewBalanceRequestModel.getMbmBkmsNumber()));
return viewBalanceResponseModel; return viewBalanceResponseModel;
} }
@GetMapping(UCOURI.FETCH_LOGIIN_DATA) @GetMapping(UCOURI.FETCH_LOGIIN_DATA)
public CustomerProfile fetchlogindata( public CustomerProfile fetchlogindata(
@RequestParam String porOrgacode, @RequestParam String porOrgacode,
@ -57,9 +58,9 @@ public class UserController {
@GetMapping(UCOURI.FETCH_DEPOSITACCOUNTS) @GetMapping(UCOURI.FETCH_DEPOSITACCOUNTS)
public List<AccountDetail> getDepositAccounts( public List<AccountDetail> getDepositAccounts(
@RequestParam String porOrgacode, @RequestParam String porOrgacode,
@RequestParam String custcode, @RequestParam String cmpCustcode,
@RequestParam String pctcstycode) { @RequestParam String pctCstycode) {
return List.of(ucoAccountService.fetchdepositAccountFromCiihive(porOrgacode,custcode)); return List.of(ucoAccountService.fetchdepositAccountFromCiihive(porOrgacode,cmpCustcode));
} }
@GetMapping(UCOURI.FETCH_ACCOUNT_STATEMENT) @GetMapping(UCOURI.FETCH_ACCOUNT_STATEMENT)
@ -93,18 +94,13 @@ public class UserController {
return new AccountInquiryResponse(ucoAccountService.fetchAccountTitile(porOrgacode,acntTypeCode,acntTypeValue)); return new AccountInquiryResponse(ucoAccountService.fetchAccountTitile(porOrgacode,acntTypeCode,acntTypeValue));
} }
@PostMapping(UCOURI.GET_TRANSACTION_PIN) // mine
public TransactionPinResponseModel submitTransaction(@RequestBody TransactionPinRequestModel transactionPinRequestModel) {
TransactionPinResponseModel response = new TransactionPinResponseModel(); // @PostMapping(UCOURI.SUBMIT_TRANSACTION)
response.setOtdTranrequestid(123456); // public TransactionResponseModel submitTransaction(@RequestBody TransactionRequestModel transactionRequestModel) {
return response; // String mockTranID = "TRAN1234567890";
} // mine // return new TransactionResponseModel(mockTranID);
// }
@PostMapping(UCOURI.SUBMIT_TRANSACTION)
public TransactionResponseModel submitTransaction(@RequestBody TransactionRequestModel transactionRequestModel) {
String mockTranID = "TRAN1234567890";
return new TransactionResponseModel(mockTranID);
}
@PostMapping(UCOURI.GENERATE_TRANSACTIONS_REPORT) @PostMapping(UCOURI.GENERATE_TRANSACTIONS_REPORT)
public String generateReport(@RequestBody TransactionHistoryRequest request) { public String generateReport(@RequestBody TransactionHistoryRequest request) {
@ -158,4 +154,10 @@ public class UserController {
return ResponseEntity.internalServerError().body("An unexpected error occurred."); return ResponseEntity.internalServerError().body("An unexpected error occurred.");
} }
} }
@GetMapping(UCOURI.FETCH_EXCHANGE_RATE)
public Object fetchExchangeRate(
@RequestParam String porOrgacode) {
return ucoAccountService.fetchExchangeRate(porOrgacode);
}
} }

@ -0,0 +1,33 @@
package com.mfsys.uco.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CashInTransactionRequest {
private String porOrgacode;
private String pctCstycode;
private String channelCode;
private String cmpCustcode;
private String drMbmBkmsnumber;
private String drMbmBkmstitle;
private String drPcrCurrcode;
private String drPcrCurrdesc;
private String crMbmBkmsnumber;
private String crMbmBkmstitle;
private String crPcrCurrcode;
private String crPcrCurrdesc;
private String sgtGntrnarration;
private String dmpProdCode;
private String transType;
private String notificationId;
private String transMode;
private double sgtGntramtfc;
private String otdTrancomment;
private boolean isOtpRequired;
}

@ -0,0 +1,18 @@
package com.mfsys.uco.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CashOutTransactionRequest {
private Long id;
private String cmpTranpin;
private boolean isAccepted;
private String cmpCustcode;
private String porOrgacode;
}

@ -17,4 +17,5 @@ public class ChangeTransactionPinRequest {
private String porOrgacode; private String porOrgacode;
private String cmpCustcode; private String cmpCustcode;
private boolean isOtpRequired; private boolean isOtpRequired;
private String pinType;
} }

@ -0,0 +1,18 @@
package com.mfsys.uco.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CoreCashInTransaction {
private String porOrgacode;
private String drMbmBkmsnumber;
private double sgtGntramtfc;
private String drPcrCurrcode;
private String otdTrancomment;
}

@ -0,0 +1,20 @@
package com.mfsys.uco.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class CoreCashOutTransaction {
private String porOrgacode;
private String crMbmBkmsnumber;
private BigDecimal sgtGntramtfc;
private String crPcrCurrcode;
private String otdTrancomment;
}

@ -16,6 +16,7 @@ public class CreateTransactionPinRequest {
private String porOrgacode; private String porOrgacode;
private String cmpCustcode; private String cmpCustcode;
private boolean isOtpRequired; private boolean isOtpRequired;
private String pinType;
} }

@ -0,0 +1,16 @@
package com.mfsys.uco.dto.Transaction;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@Data
@RequiredArgsConstructor
public class TransactionOtpRequestModel {
private String porOrgacode;
private String pctCstycode;
private String channelCode;
private String cmpCustcode;
private String email;
private String pinType;
private String transPincode;
private boolean isOtpRequired;
}

@ -10,5 +10,5 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor @AllArgsConstructor
@NoArgsConstructor @NoArgsConstructor
public class TransactionPinResponseModel { public class TransactionPinResponseModel {
private double otdTranrequestid; private Long notificationId;
} }

@ -0,0 +1,11 @@
package com.mfsys.uco.exception;
import com.mfsys.comm.exception.ApplicationException;
import com.mfsys.comm.exception.ERRCode;
public class AccountDoesntExistsException extends ApplicationException {
public AccountDoesntExistsException() {
super(null, ERRCode.ACCOUNT_NOT_FOUND, null);
}
}

@ -55,6 +55,7 @@ public class CustomerProfile {
@Column(name = "CMP_UNVERIFIED_TRAN_PIN", nullable=true, columnDefinition=FieldNameLength.PIN_VALUE) @Column(name = "CMP_UNVERIFIED_TRAN_PIN", nullable=true, columnDefinition=FieldNameLength.PIN_VALUE)
protected String cmpUnverifiedTranpin; protected String cmpUnverifiedTranpin;
@Column(name = "CMP_TRAN_PIN_VERIFIED", nullable=false, columnDefinition=FieldNameLength.BOOLEAN_BIT) @Column(name = "CMP_TRAN_PIN_VERIFIED", nullable=false, columnDefinition=FieldNameLength.BOOLEAN_BIT)
protected boolean cmpTranpinVerfied = false; protected boolean cmpTranpinVerfied = false;
} }

@ -0,0 +1,79 @@
package com.mfsys.uco.model;
import com.mfsys.comm.util.FieldNameLength;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDate;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@Entity(name = "BN_MS_UA_UCOACCOUNTTRAIL")
@Table(name = "BN_MS_UA_UCOACCOUNTTRAIL")
public class TransactionTrail {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "POR_ORGACODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.POR_ORGACODE)
protected String porOrgacode;
@Column(name = "DR_MBM_BKMSNUMBER", nullable = false, updatable = false, columnDefinition = FieldNameLength.ACCOUNT_NUMBER)
protected String drMbmBkmsnumber;
@Column(name = "CR_MBM_BKMSNUMBER", nullable = false, updatable = false, columnDefinition = FieldNameLength.ACCOUNT_NUMBER)
protected String crMbmBkmsnumber;
@Column(name = "DMP_PRODCODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.DMP_PRODCODE)
protected String dmpProdcode;
@Column(name = "DR_MBM_BKMSTITLE", nullable = false, updatable = true, columnDefinition = FieldNameLength.ACCOUNT_TITLE)
protected String drmbmBkmstitle;
@Column(name = "DR_PCR_CURRDESC", nullable=false, columnDefinition=FieldNameLength.DESCRIPTION_LONG)
private String drpcrCurrdesc;
@Column(name = "CMP_CUSTCODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.CUSTOMER_CODE)
protected String cmpCustcode;
@Column(name = "DR_PCR_CURRCODE", columnDefinition=FieldNameLength.PCR_CURRCODE)
private String drPcrCurrcode;
@Column(name = "CR_MBM_BKMSTITLE", nullable = false, updatable = true, columnDefinition = FieldNameLength.ACCOUNT_TITLE)
protected String crMbmBkmstitle;
@Column(name = "CR_PCR_CURRDESC", nullable=false, columnDefinition=FieldNameLength.DESCRIPTION_LONG)
private String crPcrCurrdesc;
@Column(name = "CR_PCR_CURRCODE", columnDefinition=FieldNameLength.PCR_CURRCODE)
private String crPcrCurrcode;
@Column(name = "SGT_SENTGNTRNUMBER", nullable = false, updatable = false, columnDefinition = FieldNameLength.CODE_500)
protected String sgtSentGntrnumber;
@Column(name = "DR_SGT_GNTRDATE", nullable = false, updatable = false, columnDefinition = FieldNameLength.DATE)
protected LocalDate drSgtGntrdate;
@Column(name = "CR_SGT_GNTRDATE", nullable = true, updatable = false, columnDefinition = FieldNameLength.DATE)
protected LocalDate crSgtGntrdate;
@Column(name = "SGT_GNTRAMT", nullable = false, updatable = false, columnDefinition = FieldNameLength.AMOUNT_REAL)
protected BigDecimal sgtGntramt = BigDecimal.ZERO;
@Column(name = "BAT_ACNTTRANSENT", nullable = false, columnDefinition = FieldNameLength.BOOLEAN_BIT)
protected boolean batAcnttranSend;
@Column(name = "BAT_ACNTTRANRECEIVED", nullable = true, columnDefinition = FieldNameLength.BOOLEAN_BIT)
protected boolean batAcnttranReceived;
@Column(name = "SGT_RECEIVEGNTRNUMBER", nullable = true, updatable = false, columnDefinition = FieldNameLength.CODE_500)
protected String sgtReceiveGntrnumber;
}

@ -9,7 +9,7 @@ import java.util.Optional;
@Repository @Repository
public interface PinRepository extends JpaRepository<Pin, Long> { public interface PinRepository extends JpaRepository<Pin, Long> {
@Query("SELECT p FROM DG_PN_PIN p WHERE p.userName = :username AND p.pinstatus = 'Unverified' AND p.pinExpirydate > CURRENT_TIMESTAMP ORDER BY p.pinserial DESC LIMIT 1") @Query("SELECT p FROM DG_PN_PIN p WHERE p.userName = :username AND p.pinstatus = 'Unverified' AND p.pinExpirydate > CURRENT_TIMESTAMP AND p.pintype=:pinType ORDER BY p.pinserial DESC LIMIT 1")
Optional<Pin> findLatestActiveOtpByUserName(String username); Optional<Pin> findLatestActiveOtpByUserName(String username,String pinType);
} }

@ -0,0 +1,14 @@
package com.mfsys.uco.repository;
import com.mfsys.uco.model.TransactionTrail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import java.util.List;
import java.util.Optional;
@Repository
public interface TransactionTrailRepository extends JpaRepository<TransactionTrail,Integer> {
Optional<List<TransactionTrail>> findByPorOrgacodeAndCrMbmBkmsnumberAndBatAcnttranReceivedFalse(String porOrgacode, String crMbmBkmsnumber);
}

@ -6,7 +6,6 @@ import com.mfsys.comm.exception.InvalidOTPException;
import com.mfsys.uco.dto.OTPRequest; import com.mfsys.uco.dto.OTPRequest;
import com.mfsys.uco.model.Pin; import com.mfsys.uco.model.Pin;
import com.mfsys.uco.repository.PinRepository; import com.mfsys.uco.repository.PinRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.client.loadbalancer.LoadBalanced; import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.WebClient;
@ -29,7 +28,7 @@ public class NotificationService {
this.pinRepository = pinRepository; this.pinRepository = pinRepository;
} }
public Mono<String> sendOtp(OTPRequest otpRequest) { public Long sendOtp(OTPRequest otpRequest) {
String otp = otpRequest.isOtpRequired() ? otpService.generateOtp() : "123456"; String otp = otpRequest.isOtpRequired() ? otpService.generateOtp() : "123456";
Pin pin = new Pin(); Pin pin = new Pin();
final LocalDateTime createDate = LocalDateTime.now(); final LocalDateTime createDate = LocalDateTime.now();
@ -48,11 +47,11 @@ public class NotificationService {
webClient.post().uri("/notification/otp/email").bodyValue(Map.of("email", otpRequest.getEmail(), "subject", otpRequest.getSubject(), "otp", otp, "userName", otpRequest.getUsername())).retrieve() webClient.post().uri("/notification/otp/email").bodyValue(Map.of("email", otpRequest.getEmail(), "subject", otpRequest.getSubject(), "otp", otp, "userName", otpRequest.getUsername())).retrieve()
.onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), clientResponse .onStatus(status -> status.is4xxClientError() || status.is5xxServerError(), clientResponse
-> Mono.error(new RuntimeException("Response has error status."))).bodyToMono(String.class).block(); -> Mono.error(new RuntimeException("Response has error status."))).bodyToMono(String.class).block();
return null; return pin.getPinserial();
} }
public void verifyOtp(String porOrgacode, String email, String obpPincode) { public void verifyOtp(String porOrgacode, String email, String obpPincode,String pinType) {
Optional<Pin> pin = pinRepository.findLatestActiveOtpByUserName(email); Optional<Pin> pin = pinRepository.findLatestActiveOtpByUserName(email,pinType);
if (pin.isPresent() && pin.get().getPincode().equals(obpPincode) && pin.get().getPorOrgacode().equals(porOrgacode)) { if (pin.isPresent() && pin.get().getPincode().equals(obpPincode) && pin.get().getPorOrgacode().equals(porOrgacode)) {
pin.get().setPinstatus("VERIFIED"); pin.get().setPinstatus("VERIFIED");
pinRepository.save(pin.get()); pinRepository.save(pin.get());

@ -25,13 +25,13 @@ public class TransactionPinService {
public void createTransactionPin(CreateTransactionPinRequest request) { public void createTransactionPin(CreateTransactionPinRequest request) {
CustomerProfile profile = fetchCustomer(request.getPorOrgacode(), request.getCmpCustcode()); CustomerProfile profile = fetchCustomer(request.getPorOrgacode(), request.getCmpCustcode());
profile.setCmpTranpin(request.getNewTransPincode()); profile.setCmpTranpin(request.getNewTransPincode());
sendOtp(profile, request.getChannelCode(), "C_PIN", "Create Transaction Pin Verification OTP", request.isOtpRequired()); sendOtp(profile, request.getChannelCode(), request.getPinType(), "Create Transaction Pin Verification OTP", request.isOtpRequired());
customerProfileRepository.save(profile); customerProfileRepository.save(profile);
} }
public boolean verifyOTPAndSavePin(VerifyPinRequest request) { public boolean verifyOTPAndSavePin(VerifyPinRequest request) {
notificationService.verifyOtp(request.getPorOrgacode(), request.getEmail(), request.getObpPincode()); notificationService.verifyOtp(request.getPorOrgacode(), request.getEmail(), request.getObpPincode(), request.getPinType());
CustomerProfile profile = fetchCustomer(request.getPorOrgacode(), request.getCmpCustcode()); CustomerProfile profile = fetchCustomer(request.getPorOrgacode(), request.getCmpCustcode());
if(Objects.nonNull(profile.getCmpUnverifiedTranpin())) { if(Objects.nonNull(profile.getCmpUnverifiedTranpin())) {
profile.setCmpTranpin(profile.getCmpUnverifiedTranpin()); profile.setCmpTranpin(profile.getCmpUnverifiedTranpin());
@ -53,16 +53,16 @@ public class TransactionPinService {
validateOldPin(profile, request.getOldTransPincode()); validateOldPin(profile, request.getOldTransPincode());
profile.setCmpUnverifiedTranpin(request.getNewTransPincode()); profile.setCmpUnverifiedTranpin(request.getNewTransPincode());
customerProfileRepository.save(profile); customerProfileRepository.save(profile);
sendOtp(profile, request.getChannelCode(), "U_PIN", "Change Transaction Pin Verification OTP", request.isOtpRequired()); sendOtp(profile, request.getChannelCode(), request.getPinType(), "Change Transaction Pin Verification OTP", request.isOtpRequired());
} }
private void validateOldPin(CustomerProfile profile, String oldPin) { public void validateOldPin(CustomerProfile profile, String oldPin) {
if (!profile.getCmpTranpin().equals(oldPin)) { if (!profile.getCmpTranpin().equals(oldPin)) {
throw new OldPinIncorrectException(); throw new OldPinIncorrectException();
} }
} }
private void sendOtp(CustomerProfile profile, String channelCode, String pinType, String subject, boolean isOtpRequired) { public Long sendOtp(CustomerProfile profile, String channelCode, String pinType, String subject, boolean isOtpRequired) {
OTPRequest otpRequest = OTPRequest.builder() OTPRequest otpRequest = OTPRequest.builder()
.porOrgacode(profile.getPorOrgacode()) .porOrgacode(profile.getPorOrgacode())
.channelCode(channelCode) .channelCode(channelCode)
@ -73,7 +73,7 @@ public class TransactionPinService {
.username(profile.getCmpUserName()) .username(profile.getCmpUserName())
.subject(subject) .subject(subject)
.build(); .build();
notificationService.sendOtp(otpRequest); return notificationService.sendOtp(otpRequest);
} }
} }

@ -1,9 +1,114 @@
package com.mfsys.uco.service; package com.mfsys.uco.service;
import com.mfsys.comm.util.FunctionReturnDetail;
import com.mfsys.uco.UCOURI;
import com.mfsys.uco.dto.*;
import com.mfsys.uco.dto.Transaction.TransactionOtpRequestModel;
import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.model.TransactionTrail;
import com.mfsys.uco.repository.CustomerProfileRepository;
import com.mfsys.uco.repository.TransactionTrailRepository;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@Service @Service
@Data
@RequiredArgsConstructor
public class TransactionService { public class TransactionService {
private final CustomerProfileRepository customerProfileRepository;
private final NotificationService notificationService;
private final TransactionPinService transactionPinService;
private final TransactionTrailRepository transactionTrailRepository;
private final WebClientDepositService webClientDepositService;
public TransactionPinResponseModel sendOtpAndValidateTranPin(TransactionOtpRequestModel transactionOtpRequestModel){
CustomerProfile customerProfile = verifyOldPinAndGetCmpProfile(transactionOtpRequestModel.getPorOrgacode(),
transactionOtpRequestModel.getTransPincode(),transactionOtpRequestModel.getCmpCustcode());
return TransactionPinResponseModel.builder().notificationId(transactionPinService.sendOtp(customerProfile, transactionOtpRequestModel.getChannelCode(),
transactionOtpRequestModel.getPinType(), "Transaction Verification OTP", transactionOtpRequestModel.isOtpRequired())).build();
}
public FunctionReturnDetail<String> cashInTransaction(CashInTransactionRequest transactionRequest) {
TransactionTrail transactionTrail = TransactionTrail.builder()
.porOrgacode(transactionRequest.getPorOrgacode())
.drMbmBkmsnumber(transactionRequest.getDrMbmBkmsnumber())
.crMbmBkmsnumber(transactionRequest.getCrMbmBkmsnumber())
.dmpProdcode(transactionRequest.getDmpProdCode())
.drmbmBkmstitle(transactionRequest.getDrMbmBkmstitle())
.drpcrCurrdesc(transactionRequest.getCrPcrCurrcode())
.cmpCustcode(transactionRequest.getCmpCustcode())
.drPcrCurrcode(transactionRequest.getDrPcrCurrcode())
.crMbmBkmstitle(transactionRequest.getCrMbmBkmstitle())
.crPcrCurrdesc(transactionRequest.getCrPcrCurrdesc())
.crPcrCurrcode(transactionRequest.getCrPcrCurrcode())
.sgtSentGntrnumber(null)
.drSgtGntrdate(LocalDate.now())
.sgtGntramt(BigDecimal.valueOf(transactionRequest.getSgtGntramtfc()))
.batAcnttranSend(false)
.batAcnttranReceived(false)
.sgtReceiveGntrnumber(null)
.build();
CoreCashInTransaction coreCashInTransaction = CoreCashInTransaction.builder()
.drMbmBkmsnumber(transactionRequest.getDrMbmBkmsnumber())
.drPcrCurrcode("123")
.sgtGntramtfc(transactionRequest.getSgtGntramtfc())
.otdTrancomment(transactionRequest.getOtdTrancomment())
.porOrgacode(transactionRequest.getPorOrgacode())
.build();
FunctionReturnDetail<String> response = (FunctionReturnDetail<String>) webClientDepositService.postTransaction(coreCashInTransaction, UCOURI.BANKING_CASH_IN,transactionRequest.getPorOrgacode());
transactionTrail.setSgtSentGntrnumber(extractTranNumber(response));
transactionTrail.setBatAcnttranSend(true);
transactionTrailRepository.save(transactionTrail);
return response;
}
public List<TransactionTrail> fetchPendingCrTransactions(String porOrgacode, String mbmBkmsnumber) {
Optional<List<TransactionTrail>> optionalTransactions = transactionTrailRepository.findByPorOrgacodeAndCrMbmBkmsnumberAndBatAcnttranReceivedFalse(porOrgacode, mbmBkmsnumber);
return optionalTransactions.orElseGet(Collections::emptyList);
}
public void cashOutTransaction(CashOutTransactionRequest cashOutTransactionRequest) {
verifyOldPinAndGetCmpProfile(cashOutTransactionRequest.getPorOrgacode(),
cashOutTransactionRequest.getCmpTranpin(),cashOutTransactionRequest.getCmpCustcode());
Optional<TransactionTrail> transactionTrail = transactionTrailRepository.findById(Math.toIntExact(cashOutTransactionRequest.getId()));
transactionTrail.ifPresent(tran -> {
CoreCashOutTransaction cashOutTransaction = CoreCashOutTransaction.builder()
.crPcrCurrcode("123")
.crMbmBkmsnumber(tran.getCrMbmBkmsnumber())
.porOrgacode(cashOutTransactionRequest.getPorOrgacode())
.otdTrancomment(cashOutTransactionRequest.getId()+"_Received")
.sgtGntramtfc(tran.getSgtGntramt())
.build();
FunctionReturnDetail<String> response = webClientDepositService.postTransaction(cashOutTransaction,UCOURI.BANKING_CASH_OUT,tran.getPorOrgacode());
tran.setSgtReceiveGntrnumber(extractTranNumber(response));
tran.setBatAcnttranReceived(true);
transactionTrailRepository.save(tran);
});
}
private CustomerProfile verifyOldPinAndGetCmpProfile(String porOrgacode, String transPincode,String cmpCustcode) {
CustomerProfile customerProfile = transactionPinService.fetchCustomer(porOrgacode,
cmpCustcode);
transactionPinService.validateOldPin(customerProfile,transPincode);
return customerProfile;
}
private String extractTranNumber(FunctionReturnDetail<String> response){
Object[] args = response.getArguments();
if (args != null && args.length > 0 && args[0] instanceof String) {
return (String) args[0];
}
throw new RuntimeException("may day");
}
} }

@ -4,18 +4,17 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.mfsys.uco.constants.UCOURI; import com.mfsys.uco.constants.UCOURI;
import com.mfsys.uco.dto.SignupStep3RequestModel; import com.mfsys.uco.dto.SignupStep3RequestModel;
import com.mfsys.uco.dto.webclientdto.AccountDetail; import com.mfsys.uco.dto.webclientdto.AccountDetail;
import com.mfsys.uco.exception.AccountDoesntExistsException;
import com.mfsys.uco.model.AccountId; import com.mfsys.uco.model.AccountId;
import com.mfsys.uco.model.CustomerProfile; import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.model.UcoAccount; import com.mfsys.uco.model.UcoAccount;
import com.mfsys.uco.repository.CustomerProfileRepository; import com.mfsys.uco.repository.CustomerProfileRepository;
import com.mfsys.uco.repository.UCOAccountRepository; import com.mfsys.uco.repository.UCOAccountRepository;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import java.math.BigDecimal;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects;
@Service @Service
@ -37,6 +36,9 @@ public class UcoAccountService {
public String fetchAccountTitile(String porOrgacode, String acntTypeCode, String acntTypeValue){ public String fetchAccountTitile(String porOrgacode, String acntTypeCode, String acntTypeValue){
if(acntTypeCode.equals("01")){ if(acntTypeCode.equals("01")){
CustomerProfile customerProfile = customerProfileRepository.findProfilesByMobilePhone(porOrgacode,acntTypeValue); CustomerProfile customerProfile = customerProfileRepository.findProfilesByMobilePhone(porOrgacode,acntTypeValue);
if(Objects.isNull(customerProfile)){
throw new AccountDoesntExistsException();
}
return ucoAccountRepository.findUcoAccountByCmpCustcode(porOrgacode,customerProfile.getCmpCustcode()).getMbmBkmstitle(); return ucoAccountRepository.findUcoAccountByCmpCustcode(porOrgacode,customerProfile.getCmpCustcode()).getMbmBkmstitle();
} }
return null; return null;
@ -90,5 +92,10 @@ public class UcoAccountService {
return objectMapper.convertValue(map.get(0), AccountDetail.class); return objectMapper.convertValue(map.get(0), AccountDetail.class);
} }
public Object fetchExchangeRate(String porOrgacode){
String url= UCOURI.FETCH_EXCHANGE_RATE+"?porOrgacode="+porOrgacode;
return webClientDeposit.fetchExchangeRate(url,porOrgacode);
}
} }

@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.mfsys.comm.exception.ApplicationException; import com.mfsys.comm.exception.ApplicationException;
import com.mfsys.comm.exception.ApplicationExceptionMapper; import com.mfsys.comm.exception.ApplicationExceptionMapper;
import com.mfsys.comm.util.FunctionReturnDetail;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -37,6 +38,22 @@ public class WebClientDepositService {
.header("POR_ORGACODE", porOrgacode).retrieve().toEntity(Object.class), .header("POR_ORGACODE", porOrgacode).retrieve().toEntity(Object.class),
null); null);
} }
public FunctionReturnDetail postTransaction(Object tranData, String url, String porOrgaCode) {
return handleResponse(webClientDeposit.post().uri(url).bodyValue(tranData).accept(MediaType.APPLICATION_JSON)
.header("SUS_USERCODE", porOrgaCode)
.header("POR_ORGACODE", porOrgaCode).retrieve()
.toEntity(FunctionReturnDetail.class),
porOrgaCode);
}
public Object fetchExchangeRate(String url,String porOrgacode) {
return handleResponse(webClientDeposit.get().uri(url).accept(MediaType.APPLICATION_JSON)
.header("SUS_USERCODE", porOrgacode)
.header("POR_ORGACODE", porOrgacode).retrieve().toEntity(Object.class),
null);
}
private <T> T handleResponse(Mono<ResponseEntity<T>> responseMono, String porgaCode) { private <T> T handleResponse(Mono<ResponseEntity<T>> responseMono, String porgaCode) {
try { try {

@ -0,0 +1,2 @@
#base.ciihive=localhost
base.ciihive=${CIIHIVE_URL}

@ -29,10 +29,10 @@ eureka:
service-url: service-url:
defaultZone: http://localhost:8761/eureka defaultZone: http://localhost:8761/eureka
#application: application:
# security: security:
# jwt: jwt:
# secret-key: 404E635266556A586E3272357538782F413F4428472B4B6250645367566B5970 secret-key: 404E635266556A586E3272357538782F413F4428472B4B6250645367566B5970
# expiration: 86400000 expiration: 86400000
# refresh-token: refresh-token:
# expiration: 604800000 # 7 days expiration: 604800000 # 7 days
Loading…
Cancel
Save