commit
parent
7c46dbf603
commit
19ee585df7
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -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;
|
||||||
|
|
||||||
|
}
|
||||||
@ -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);
|
||||||
|
}
|
||||||
@ -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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,2 @@
|
|||||||
|
#base.ciihive=localhost
|
||||||
|
base.ciihive=${CIIHIVE_URL}
|
||||||
Loading…
Reference in New Issue