Nabeel-DG-BS
Raja Nabeel 2 years ago
parent 06f486bc85
commit 7c46dbf603

@ -2,6 +2,7 @@ package com.mfsys.uco;
public interface UCOURI {
String VIEW_BALANCE = "/user/viewBalance";
String ONBOARD_CUSTOMER = "/user/onboardCutomer";
String FETCH_DEPOSITACCOUNTS = "/depositAccounts";
String FETCH_ACCOUNT_STATEMENT = "/accountStatement";
String FETCH_ACCOUNT_INQUIRY = "/accountInquiry";
@ -11,4 +12,5 @@ public interface UCOURI {
String CREATE_TRAN_PIN = "/createTransactionPin";
String VERIFY_TRAN_PIN = "/verifyTransactionPin";
String CHANGE_TRAN_PIN = "/changeTransactionPin";
String FETCH_LOGIIN_DATA = "/fetchlogindata";
}

@ -19,6 +19,11 @@ public class WebClientconfiguration {
return WebClient.create("http://localhost:9095");
}
@Bean
public WebClient webClientCrm() {
return WebClient.create("http://localhost:9096");
}
}

@ -2,4 +2,6 @@ package com.mfsys.uco.constants;
public interface UCOURI {
String GET_UCOACC_BALANCE = "/deposit/getUcoAccountBalance";
String CUSTOMER_ONBOARDING = "/crm/onboarding/digital/customer";
String GET_CMP_UCOACCOUNTS = "/deposit/getUcoAccounts";
}

@ -6,8 +6,11 @@ import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.Paragraph;
import com.mfsys.uco.UCOURI;
import com.mfsys.uco.dto.*;
import com.mfsys.uco.dto.webclientdto.AccountDetail;
import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.model.UcoAccount;
import com.mfsys.uco.repository.UCOAccountRepository;
import com.mfsys.uco.service.CustomerProfileService;
import com.mfsys.uco.service.TransactionPinService;
import com.mfsys.uco.service.TransactionService;
import com.mfsys.uco.service.UcoAccountService;
@ -29,34 +32,34 @@ public class UserController {
private final TransactionPinService transactionPinService;
private final TransactionService transactionService;
private final UcoAccountService ucoAccountService;
private final CustomerProfileService customerProfileService;
@PostMapping(UCOURI.ONBOARD_CUSTOMER)
public ResponseEntity<HttpStatus> customerOnBoarding(@RequestBody SignupStep3RequestModel signupStep3RequestModel) {
ucoAccountService.onBoardCustomer(signupStep3RequestModel);
return null;
}
@PostMapping(UCOURI.VIEW_BALANCE)
public ViewBalanceResponseModel viewBalance(@RequestBody ViewBalanceRequestModel viewBalanceRequestModel) {
ViewBalanceResponseModel viewBalanceResponseModel = new ViewBalanceResponseModel();
viewBalanceResponseModel.setMbmBkmsbalance(ucoAccountService.fetchAccountBalance(viewBalanceRequestModel.getPorOrgacode(),viewBalanceRequestModel.getMbmBkmsNumber()));
return viewBalanceResponseModel;
}
@GetMapping(UCOURI.FETCH_LOGIIN_DATA)
public CustomerProfile fetchlogindata(
@RequestParam String porOrgacode,
@RequestParam String email) {
return customerProfileService.fetchCustcodeBasedOnEmail(porOrgacode,email);
}
@GetMapping(UCOURI.FETCH_DEPOSITACCOUNTS)
public List<DepositAccount> getDepositAccounts(
public List<AccountDetail> getDepositAccounts(
@RequestParam String porOrgacode,
@RequestParam String custcode,
@RequestParam String pctcstycode) {
List<DepositAccount> accounts = new ArrayList<>();
DepositAccount account = new DepositAccount();
account.setPorOrgacode(porOrgacode);
account.setMbmBkmsnumber("123456789");
account.setPcrCurrdesc("US Dollars");
account.setPcrCurrCode("USD");
account.setPctCstycode(pctcstycode);
account.setMbmBkmstitle("Savings Account");
account.setMbmBkmsbalance(new BigDecimal("1000.00"));
account.setMbmBkmsopendate("2021-01-01");
account.setAccountType("SAVINGS");
accounts.add(account);
return accounts;
return List.of(ucoAccountService.fetchdepositAccountFromCiihive(porOrgacode,custcode));
}
@GetMapping(UCOURI.FETCH_ACCOUNT_STATEMENT)

@ -0,0 +1,27 @@
package com.mfsys.uco.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SignupStep3RequestModel {
private String username;
private String email;
private String phone;
private String name;
private String address;
private String identificationType;
private String identificationNumber;
private boolean isKycAdded;
private String kycType;
private String kycDocumentId1; // base64 encoded
private String kycDocumentId2; // base64 encoded
private String userRole;
private String channelCode;
private String porOrgacode;
}

@ -0,0 +1,49 @@
package com.mfsys.uco.dto.webclientdto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.Map;
@Data
@RequiredArgsConstructor
@AllArgsConstructor
@Builder
public class AccountDetail {
protected String porOrgacode;
protected String mbmBkmsnumber;
protected String mbmBkmstitle;
protected String dmpProddesc;
protected String plcLocadesc;
protected String pcrCurrcode;
protected String pcrCurrdesc;
protected String cmpCustcode;
protected boolean mbmBkmsclosed;
protected String pctCstycode;
protected BigDecimal mbmBkmsbalance;
protected Map<String, BigDecimal> charges = Map.of();
protected String dmpProdcode;
protected boolean cmpBlacklisted;
protected String plcLocacode;
protected boolean mbmNotificationService;
protected String dmpCredittype;
protected BigDecimal perEratrateact;
protected LocalDate kycRenewalDate;
protected String padAdrsmobphone;
protected boolean btaRolloverSpecialRate;
private String pasAcstcode;
private BigDecimal btaBookingamount;
private BigDecimal bdaDpacblockamt;
private boolean bdaDpacblocked;
private String pbdBankname;
private String pbbBranchname;
private String pbbBranchcountry;
private String pbbBranchcity;
private String pcaGlaccode;
private String accJointStatus;
private String accAttortype;
}

@ -50,7 +50,7 @@ public class CustomerProfile {
@Column(name = "CMP_ISKYC_VERIFIED", nullable=false, columnDefinition=FieldNameLength.BOOLEAN_BIT)
protected boolean cmpIsKycVerified = false;
@Column(name = "CMP_TRAN_PIN", nullable=false, columnDefinition=FieldNameLength.PIN_VALUE)
@Column(name = "CMP_TRAN_PIN", nullable=true, columnDefinition=FieldNameLength.PIN_VALUE)
protected String cmpTranpin;
@Column(name = "CMP_UNVERIFIED_TRAN_PIN", nullable=true, columnDefinition=FieldNameLength.PIN_VALUE)

@ -1,10 +1,7 @@
package com.mfsys.uco.model;
import com.mfsys.comm.util.FieldNameLength;
import jakarta.persistence.Column;
import jakarta.persistence.EmbeddedId;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
@ -22,16 +19,21 @@ public class UcoAccount {
@EmbeddedId
private AccountId id;
@Column(name = "DMP_PRODCODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.DMP_PRODCODE)
protected String dmpProdcode;
@Column(name = "MBM_BKMSTITLE", nullable = false, updatable = true, columnDefinition = FieldNameLength.ACCOUNT_TITLE)
protected String mbmBkmstitle;
@Column(name = "PCR_CURRDESC", nullable=false, columnDefinition=FieldNameLength.DESCRIPTION_LONG)
private String pcrCurrdesc;
@Column(name = "CMP_CUSTCODE", nullable = false, updatable = false, columnDefinition = FieldNameLength.CUSTOMER_CODE)
protected String cmpCustcode;
@Column(name = "PCR_CURRCODE", columnDefinition=FieldNameLength.PCR_CURRCODE)
private String pcrCurrcode;
@Column(name = "MBM_BKMSCLOSED", nullable = false, columnDefinition = FieldNameLength.BOOLEAN_BIT)
protected boolean mbmBkmsclosed;

@ -10,4 +10,6 @@ import org.springframework.stereotype.Repository;
public interface CustomerProfileRepository extends JpaRepository<CustomerProfile, CustomerProfileId> {
@Query("SELECT c FROM BN_CS_MP_CUSTOMERPROFILE c WHERE c.porOrgacode =:porOrgacode and c.padAdrsmobphone = :phone")
CustomerProfile findProfilesByMobilePhone(String porOrgacode,String phone);
@Query("SELECT c FROM BN_CS_MP_CUSTOMERPROFILE c WHERE c.porOrgacode =:porOrgacode and c.cmpEmail = :email")
CustomerProfile findbyEmail(String porOrgacode, String email);
}

@ -0,0 +1,18 @@
package com.mfsys.uco.service;
import com.mfsys.uco.dto.webclientdto.AccountDetail;
import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.repository.CustomerProfileRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
@RequiredArgsConstructor
public class CustomerProfileService {
private final CustomerProfileRepository customerProfileRepository;
public CustomerProfile fetchCustcodeBasedOnEmail(String porOrgacode, String email) {
return customerProfileRepository.findbyEmail(porOrgacode,email);
}
}

@ -1,15 +1,23 @@
package com.mfsys.uco.service;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mfsys.uco.constants.UCOURI;
import com.mfsys.uco.dto.SignupStep3RequestModel;
import com.mfsys.uco.dto.webclientdto.AccountDetail;
import com.mfsys.uco.model.AccountId;
import com.mfsys.uco.model.CustomerProfile;
import com.mfsys.uco.model.UcoAccount;
import com.mfsys.uco.repository.CustomerProfileRepository;
import com.mfsys.uco.repository.UCOAccountRepository;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.List;
import java.util.Map;
@Service
public class UcoAccountService {
@ -17,11 +25,13 @@ public class UcoAccountService {
private final UCOAccountRepository ucoAccountRepository;
private final WebClientDepositService webClientDeposit;
private final WebClientCrmService webClientCrmService;
public UcoAccountService(CustomerProfileRepository customerProfileRepository, UCOAccountRepository ucoAccountRepository, WebClientDepositService webClientDeposit) {
public UcoAccountService(CustomerProfileRepository customerProfileRepository, UCOAccountRepository ucoAccountRepository, WebClientDepositService webClientDeposit, WebClientCrmService webClientCrmService) {
this.customerProfileRepository = customerProfileRepository;
this.ucoAccountRepository = ucoAccountRepository;
this.webClientDeposit = webClientDeposit;
this.webClientCrmService = webClientCrmService;
}
public String fetchAccountTitile(String porOrgacode, String acntTypeCode, String acntTypeValue){
@ -36,9 +46,49 @@ public class UcoAccountService {
public Double fetchAccountBalance(String porOrgacode, String mbmBkmsNumber) {
return (Double) getIndvAccountDetails(porOrgacode,mbmBkmsNumber);
}
public Object getIndvAccountDetails(String porOrgacode, String mbmBkmsnumber) {
String url= UCOURI.GET_UCOACC_BALANCE+"?porOrgacode="+porOrgacode+"&mbmBkmsnumber="+mbmBkmsnumber;
return webClientDeposit.getUcoAccountBalance(url,porOrgacode);
}
}
public void onBoardCustomer(SignupStep3RequestModel signupStep3RequestModel) {
String porOrgacode = signupStep3RequestModel.getPorOrgacode();
Map cmpCustcodeReturn = (Map) webClientCrmService.onboardCustomer(Map.of("CMP_FULLNAME",signupStep3RequestModel.getName()
,"PIT_IDENCODE",signupStep3RequestModel.getIdentificationType(),"CIT_IDENVALUE",signupStep3RequestModel.getIdentificationNumber()
,"PAD_ADRSMOBPHONE",signupStep3RequestModel.getPhone(),"POR_ORGACODE",signupStep3RequestModel.getPorOrgacode(),"SUS_USERCODE","01",
"PLC_LOCACODE","2003"), UCOURI.CUSTOMER_ONBOARDING,signupStep3RequestModel.getPorOrgacode());
String cmpCustcode = String.valueOf(cmpCustcodeReturn.get("cmpCustcode"));
AccountDetail accountDetail = fetchdepositAccountFromCiihive(porOrgacode,cmpCustcode);
CustomerProfile customerProfile = CustomerProfile.builder().cmpCustcode(accountDetail.getCmpCustcode()).cmpEmail(signupStep3RequestModel.getEmail())
.cmpName(signupStep3RequestModel.getName()).cmpIsKycVerified(signupStep3RequestModel.isKycAdded())
.pitIdencode(signupStep3RequestModel.getIdentificationType()).pitIdenvalue(signupStep3RequestModel.getIdentificationNumber())
.cmpUserName(signupStep3RequestModel.getName())
.padAdrsmobphone(signupStep3RequestModel.getPhone())
.cmpUserName(signupStep3RequestModel.getUsername()).porOrgacode(signupStep3RequestModel.getPorOrgacode())
.build();
customerProfileRepository.save(customerProfile);
UcoAccount ucoAccount = UcoAccount.builder()
.id(new AccountId(accountDetail.getPorOrgacode(),accountDetail.getMbmBkmsnumber())) // Set the AccountId, assuming a method exists to create or retrieve it
.dmpProdcode(accountDetail.getDmpProdcode())
.mbmBkmstitle(accountDetail.getMbmBkmstitle())
.pcrCurrdesc(accountDetail.getPcrCurrdesc())
.cmpCustcode(accountDetail.getCmpCustcode())
.pcrCurrcode(accountDetail.getPcrCurrcode())
.mbmBkmsclosed(accountDetail.isMbmBkmsclosed())
.mbmBkmsopendate(LocalDate.now())
.sgtLasttrandate(LocalDate.now())
.build();
ucoAccountRepository.save(ucoAccount);
}
public AccountDetail fetchdepositAccountFromCiihive(String porOrgacode,String cmpCustcode){
String url= UCOURI.GET_CMP_UCOACCOUNTS+"?porOrgacode="+porOrgacode+"&cmpCustcode="+cmpCustcode;
List<Object> map = (List<Object>) webClientDeposit.getCmpUcoAccounts(url,porOrgacode);
ObjectMapper objectMapper = new ObjectMapper();
return objectMapper.convertValue(map.get(0), AccountDetail.class);
}
}

@ -0,0 +1,72 @@
package com.mfsys.uco.service;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.mfsys.comm.exception.ApplicationException;
import com.mfsys.comm.exception.ApplicationExceptionMapper;
import org.apache.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.springframework.web.reactive.function.client.WebClientResponseException;
import reactor.core.publisher.Mono;
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
@Service
public class WebClientCrmService {
private final WebClient webClientCrm;
public WebClientCrmService(WebClient webClientCrm) {
this.webClientCrm = webClientCrm;
}
public Object getUcoAccountBalance(String url,String porOrgacode) {
return handleResponse(webClientCrm.get().uri(url).accept(MediaType.APPLICATION_JSON)
.header("SUS_USERCODE", porOrgacode)
.header("POR_ORGACODE", porOrgacode).retrieve().toEntity(Object.class),
null);
}
public Object onboardCustomer(Map onBoardingData, String url, String porOrgaCode) {
return handleResponse(webClientCrm.post().uri(url).bodyValue(onBoardingData).accept(MediaType.APPLICATION_JSON)
.header("SUS_USERCODE", porOrgaCode)
.header("POR_ORGACODE", porOrgaCode).retrieve()
.toEntity(Object.class),
porOrgaCode);
}
private <T> T handleResponse(Mono<ResponseEntity<T>> responseMono, String porgaCode) {
try {
ResponseEntity<T> response = responseMono.block();
return response.getBody();
} catch (WebClientResponseException e) {
ApplicationExceptionMapper.APIError errorDetails = parseErrorDetails(e);
throw new ApplicationException(porgaCode,errorDetails.getErrorCode(),errorDetails.getArguments());
}
}
private ApplicationExceptionMapper.APIError parseErrorDetails(WebClientResponseException e) {
String errorCode = null;
List<String> arguments = null;
if (e.getResponseBodyAsString() != null) {
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNode errorNode = objectMapper.readTree(e.getResponseBodyAsString());
errorCode = errorNode.get("errorCode").asText();
arguments = Arrays.asList(objectMapper.convertValue(errorNode.get("arguments"), String[].class));
} catch (IOException ex) {
}
}
return new ApplicationExceptionMapper.APIError(errorCode, arguments.toArray());
}
}

@ -31,6 +31,13 @@ public class WebClientDepositService {
null);
}
public Object getCmpUcoAccounts(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) {
try {
ResponseEntity<T> response = responseMono.block();

Loading…
Cancel
Save