first commit 04/09/2024
This commit is contained in:
Executable
+13
@@ -0,0 +1,13 @@
|
||||
package com.saslpay;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class SaslPayBkp {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(SaslPayBkp.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
|
||||
@Configuration
|
||||
public class AppPropertiesConfig {
|
||||
|
||||
@Value("${interface.out.folder}")
|
||||
public String outFolder;
|
||||
|
||||
@Value("${transactionDataTable}")
|
||||
public String transactionDataTable;
|
||||
|
||||
@Value("${t24DataTable}")
|
||||
public String t24DataTable;
|
||||
|
||||
@Bean
|
||||
public String getTransactionDataTable() {
|
||||
return transactionDataTable;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String getT24DataTable() {
|
||||
return t24DataTable;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public String getOutFolder(){
|
||||
return outFolder;
|
||||
}
|
||||
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class BeanUtil implements ApplicationContextAware {
|
||||
|
||||
private static ApplicationContext context;
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
context = applicationContext;
|
||||
}
|
||||
|
||||
public static <T> T getBean(Class<T> beanClass) {
|
||||
return context.getBean(beanClass);
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import com.saslpay.datacapture.AccountDataCapture;
|
||||
import org.apache.camel.builder.RouteBuilder;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class BuildRoute extends RouteBuilder {
|
||||
|
||||
@Value("${interface.in.folder}") String inFolder;
|
||||
|
||||
public void configure() {
|
||||
|
||||
inFolder = "file:" + "./app/intxns" + "?delete=true&readLock=changed&readLockMinAge=5s";
|
||||
from(inFolder).routeId("Account Update").log("Updating Account").streamCaching().process(exchange -> {
|
||||
String body = exchange.getIn().getBody(String.class);
|
||||
// inFileName = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
|
||||
AccountDataCapture accountDataCapture = new AccountDataCapture();
|
||||
accountDataCapture.importer(body);
|
||||
}).log("Account Update Completed");
|
||||
|
||||
// outFolder = "file:" + outFolder + "?delete=true&readLock=changed&readLockMinAge=5s";
|
||||
// from(outFolder).log("out...").streamCaching().process(exchange -> {
|
||||
// String body = exchange.getIn().getBody(String.class);
|
||||
// outFileName = exchange.getIn().getHeader(Exchange.FILE_NAME, String.class);
|
||||
// }).log("processing... " + outFileName + " done...");
|
||||
}
|
||||
}
|
||||
+77
@@ -0,0 +1,77 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import org.hibernate.jpa.HibernatePersistenceProvider;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.jdbc.DataSourceBuilder;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.PropertySource;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
import org.springframework.orm.jpa.JpaTransactionManager;
|
||||
import org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean;
|
||||
import org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.util.Properties;
|
||||
|
||||
@Configuration
|
||||
@EnableJpaRepositories(basePackages = "com.saslpay.*", transactionManagerRef = "jpaTransactionManager")
|
||||
@PropertySource(value = {"classpath:application.properties"})
|
||||
@EnableTransactionManagement
|
||||
public class JpaConfig {
|
||||
|
||||
private static final String[] ENTITYMANAGER_PACKAGES_TO_SCAN = {"com.saslpay.*"};
|
||||
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
String dialect;
|
||||
|
||||
@Bean
|
||||
public DataSource dataSource() {
|
||||
|
||||
String username = env.getProperty("spring.datasource.username");
|
||||
String password = env.getProperty("spring.datasource.password");
|
||||
// String driverClass = env.getProperty("spring.datasource.driver");
|
||||
String url = env.getProperty("spring.datasource.url");
|
||||
dialect = env.getProperty("spring.jpa.database-platform");
|
||||
return DataSourceBuilder.create().username(username).password(password).url(url).build();
|
||||
//driverClassName(driverClass).build();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public JpaTransactionManager jpaTransactionManager() {
|
||||
JpaTransactionManager transactionManager = new JpaTransactionManager();
|
||||
transactionManager.setEntityManagerFactory(entityManagerFactory().getObject());
|
||||
return transactionManager;
|
||||
}
|
||||
|
||||
//adding for future use
|
||||
private HibernateJpaVendorAdapter vendorAdaptor() {
|
||||
HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();
|
||||
return vendorAdapter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean entityManagerFactoryBean = new LocalContainerEntityManagerFactoryBean();
|
||||
entityManagerFactoryBean.setJpaVendorAdapter(vendorAdaptor());
|
||||
entityManagerFactoryBean.setDataSource(dataSource());
|
||||
entityManagerFactoryBean.setPersistenceProviderClass(HibernatePersistenceProvider.class);
|
||||
entityManagerFactoryBean.setPackagesToScan(ENTITYMANAGER_PACKAGES_TO_SCAN);
|
||||
entityManagerFactoryBean.setJpaProperties(addProperties());
|
||||
return entityManagerFactoryBean;
|
||||
}
|
||||
|
||||
private Properties addProperties() {
|
||||
Properties properties = new Properties();
|
||||
properties.setProperty("hibernate.hbm2ddl.auto", "none");
|
||||
properties.setProperty("hibernate.dialect", dialect);
|
||||
properties.setProperty("hibernate.show_sql", "false");
|
||||
// we can add
|
||||
return properties;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import org.springframework.security.core.AuthenticationException;
|
||||
import org.springframework.security.web.AuthenticationEntryPoint;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Component
|
||||
public class JwtAuthenticationEntryPoint implements AuthenticationEntryPoint, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7858869558953243875L;
|
||||
|
||||
@Override
|
||||
public void commence(HttpServletRequest request, HttpServletResponse response,
|
||||
AuthenticationException authException) {
|
||||
|
||||
try {
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unauthorized Access");
|
||||
} catch (IOException e) {
|
||||
e.getLocalizedMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
+78
@@ -0,0 +1,78 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import com.saslpay.impl.JwtUserDetailsService;
|
||||
import io.jsonwebtoken.ExpiredJwtException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.context.SecurityContextHolder;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.filter.OncePerRequestFilter;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
@Component
|
||||
public class JwtRequestFilter extends OncePerRequestFilter {
|
||||
|
||||
@Autowired
|
||||
private JwtUserDetailsService jwtUserDetailsService;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
@Override
|
||||
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
|
||||
throws ServletException, IOException {
|
||||
|
||||
final String requestTokenHeader = request.getHeader("Authorization");
|
||||
|
||||
String username = null;
|
||||
String jwtToken = null;
|
||||
// JWT Token is in the form "Bearer token". Remove Bearer word and get
|
||||
// only the Token
|
||||
//if (requestTokenHeader != null && requestTokenHeader.startsWith("Bearer ")) {
|
||||
if (requestTokenHeader != null) {
|
||||
// jwtToken = requestTokenHeader.substring(7);
|
||||
jwtToken = requestTokenHeader;
|
||||
try {
|
||||
username = jwtTokenUtil.getUsernameFromToken(jwtToken);
|
||||
} catch (IllegalArgumentException e) {
|
||||
//System.out.println("Unable to get JWT Token");
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Unable To Get Token");
|
||||
} catch (ExpiredJwtException e) {
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Token Expired");
|
||||
//System.out.println("JWT Token has expired");
|
||||
}
|
||||
} else {
|
||||
//response.sendError(HttpServletResponse.SC_UNAUTHORIZED, "Invalid Token");
|
||||
logger.warn("JWT Token does not begin with Bearer String");
|
||||
}
|
||||
|
||||
// Once we get the token validate it.
|
||||
if (username != null && SecurityContextHolder.getContext().getAuthentication() == null) {
|
||||
|
||||
UserDetails userDetails = this.jwtUserDetailsService.loadUserByUsername(username);
|
||||
|
||||
// if token is valid configure Spring Security to manually set
|
||||
// authentication
|
||||
if (jwtTokenUtil.validateToken(jwtToken, userDetails)) {
|
||||
|
||||
UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(
|
||||
userDetails, null, userDetails.getAuthorities());
|
||||
usernamePasswordAuthenticationToken
|
||||
.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));
|
||||
// After setting the Authentication in the context, we specify
|
||||
// that the current user is authenticated. So it passes the
|
||||
// Spring Security Configurations successfully.
|
||||
SecurityContextHolder.getContext().setAuthentication(usernamePasswordAuthenticationToken);
|
||||
}
|
||||
}
|
||||
chain.doFilter(request, response);
|
||||
}
|
||||
|
||||
}
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import io.jsonwebtoken.Claims;
|
||||
import io.jsonwebtoken.Jwts;
|
||||
import io.jsonwebtoken.SignatureAlgorithm;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
@Component
|
||||
public class JwtTokenUtil implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2550185165626007488L;
|
||||
|
||||
public static final long JWT_TOKEN_VALIDITY = 24 * 60 * 60;
|
||||
|
||||
@Value("${jwt.secret}")
|
||||
private String secret;
|
||||
|
||||
//retrieve username from jwt token
|
||||
public String getUsernameFromToken(String token) {
|
||||
return getClaimFromToken(token, Claims::getSubject);
|
||||
}
|
||||
|
||||
//retrieve expiration date from jwt token
|
||||
public Date getExpirationDateFromToken(String token) {
|
||||
return getClaimFromToken(token, Claims::getExpiration);
|
||||
}
|
||||
|
||||
public <T> T getClaimFromToken(String token, Function<Claims, T> claimsResolver) {
|
||||
final Claims claims = getAllClaimsFromToken(token);
|
||||
return claimsResolver.apply(claims);
|
||||
}
|
||||
//for retrieveing any information from token we will need the secret key
|
||||
private Claims getAllClaimsFromToken(String token) {
|
||||
return Jwts.parser().setSigningKey(secret).parseClaimsJws(token).getBody();
|
||||
}
|
||||
|
||||
//check if the token has expired
|
||||
private Boolean isTokenExpired(String token) {
|
||||
final Date expiration = getExpirationDateFromToken(token);
|
||||
return expiration.before(new Date());
|
||||
}
|
||||
|
||||
//generate token for user
|
||||
public String generateToken(UserDetails userDetails) {
|
||||
Map<String, Object> claims = new HashMap<>();
|
||||
return doGenerateToken(claims, userDetails.getUsername());
|
||||
}
|
||||
|
||||
//while creating the token -
|
||||
//1. Define claims of the token, like Issuer, Expiration, Subject, and the ID
|
||||
//2. Sign the JWT using the HS512 algorithm and secret key.
|
||||
//3. According to JWS Compact Serialization(https://tools.ietf.org/html/draft-ietf-jose-json-web-signature-41#section-3.1)
|
||||
// compaction of the JWT to a URL-safe string
|
||||
private String doGenerateToken(Map<String, Object> claims, String subject) {
|
||||
|
||||
return Jwts.builder().setClaims(claims).setSubject(subject).setIssuedAt(new Date(System.currentTimeMillis()))
|
||||
.setExpiration(new Date(System.currentTimeMillis() + JWT_TOKEN_VALIDITY * 1000))
|
||||
.signWith(SignatureAlgorithm.HS512, secret).compact();
|
||||
}
|
||||
|
||||
//validate token
|
||||
public Boolean validateToken(String token, UserDetails userDetails) {
|
||||
final String username = getUsernameFromToken(token);
|
||||
return (username.equals(userDetails.getUsername()) && !isTokenExpired(token));
|
||||
}
|
||||
}
|
||||
+67
@@ -0,0 +1,67 @@
|
||||
package com.saslpay.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
import org.springframework.security.config.http.SessionCreationPolicy;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
|
||||
|
||||
@Configuration
|
||||
@EnableWebSecurity
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true)
|
||||
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
|
||||
|
||||
@Autowired
|
||||
private JwtAuthenticationEntryPoint jwtAuthenticationEntryPoint;
|
||||
|
||||
@Autowired
|
||||
private UserDetailsService jwtUserDetailsService;
|
||||
|
||||
@Autowired
|
||||
private JwtRequestFilter jwtRequestFilter;
|
||||
|
||||
@Autowired
|
||||
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
|
||||
// configure AuthenticationManager so that it knows from where to load
|
||||
// user for matching credentials
|
||||
// Use BCryptPasswordEncoder
|
||||
auth.userDetailsService(jwtUserDetailsService).passwordEncoder(passwordEncoder());
|
||||
}
|
||||
|
||||
@Bean
|
||||
public PasswordEncoder passwordEncoder() {
|
||||
return new BCryptPasswordEncoder();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@Override
|
||||
public AuthenticationManager authenticationManagerBean() throws Exception {
|
||||
return super.authenticationManagerBean();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity httpSecurity) throws Exception {
|
||||
// We don't need CSRF for this example
|
||||
httpSecurity.csrf().disable()
|
||||
// dont authenticate this particular request
|
||||
.authorizeRequests().antMatchers("/cbs/security/getToken", "/cbs/register").permitAll().
|
||||
// all other requests need to be authenticated
|
||||
anyRequest().authenticated().and().
|
||||
// make sure we use stateless session; session won't be used to
|
||||
// store user's state.
|
||||
exceptionHandling().authenticationEntryPoint(jwtAuthenticationEntryPoint).and().sessionManagement()
|
||||
.sessionCreationPolicy(SessionCreationPolicy.STATELESS);
|
||||
|
||||
// Add a filter to validate the tokens with every request
|
||||
httpSecurity.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package com.saslpay.controller;
|
||||
|
||||
import com.saslpay.config.JwtTokenUtil;
|
||||
import com.saslpay.datacapture.JwtRequest;
|
||||
import com.saslpay.datacapture.JwtResponse;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import com.saslpay.entities.UserEntity;
|
||||
import com.saslpay.impl.JwtUserDetailsService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.authentication.AuthenticationManager;
|
||||
import org.springframework.security.authentication.BadCredentialsException;
|
||||
import org.springframework.security.authentication.DisabledException;
|
||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.sql.Time;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cbs")
|
||||
@CrossOrigin
|
||||
public class JwtAuthenticationController {
|
||||
|
||||
LocalDate localDate;
|
||||
LocalDateTime tokenInitTime;
|
||||
|
||||
@Autowired
|
||||
private AuthenticationManager authenticationManager;
|
||||
|
||||
@Autowired
|
||||
private JwtTokenUtil jwtTokenUtil;
|
||||
|
||||
@Autowired
|
||||
private JwtUserDetailsService userDetailsService;
|
||||
|
||||
// @RequestMapping(value = "security/getToken", method = RequestMethod.GET)
|
||||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE, value = "security/getToken")
|
||||
public String createAuthenticationToken(@RequestHeader(value="username") String username, @RequestHeader(value = "password") String password) throws Exception {
|
||||
// public String createAuthenticationToken(@RequestBody JwtRequest authenticationRequest) throws Exception {
|
||||
|
||||
authenticate(username, password);
|
||||
//authenticate(authenticationRequest.getUsername(), authenticationRequest.getPassword());
|
||||
|
||||
final UserDetails userDetails = userDetailsService
|
||||
// .loadUserByUsername(authenticationRequest.getUsername());
|
||||
.loadUserByUsername(username);
|
||||
|
||||
localDate = LocalDate.parse(new Date(System.currentTimeMillis()).toString(), DateTimeFormatter.ISO_LOCAL_DATE);
|
||||
tokenInitTime = localDate.atTime(new Time((System.currentTimeMillis())).toLocalTime());
|
||||
tokenInitTime = tokenInitTime.plusHours(24);
|
||||
|
||||
final String token = jwtTokenUtil.generateToken(userDetails);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("authToken", token);
|
||||
object.put("Status", "00");
|
||||
object.put("validUntil", tokenInitTime.toString());
|
||||
return "" + object + "";
|
||||
// return ResponseEntity.ok(new JwtResponse(token));
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/register", method = RequestMethod.POST)
|
||||
public ResponseEntity<?> saveUser(@RequestBody UserEntity user) throws Exception {
|
||||
|
||||
// if (userDetails.equals("root")){
|
||||
return ResponseEntity.ok(userDetailsService.save(user));
|
||||
// }else{
|
||||
// return ResponseEntity.ok(userDetailsService.failed(user));
|
||||
// }
|
||||
}
|
||||
|
||||
private void authenticate(String username, String password) throws Exception {
|
||||
try {
|
||||
authenticationManager.authenticate(new UsernamePasswordAuthenticationToken(username, password));
|
||||
} catch (DisabledException e) {
|
||||
throw new Exception("USER_DISABLED", e);
|
||||
} catch (BadCredentialsException e) {
|
||||
throw new Exception("INVALID_CREDENTIALS", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+260
@@ -0,0 +1,260 @@
|
||||
package com.saslpay.controller;
|
||||
|
||||
import com.saslpay.config.AppPropertiesConfig;
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import com.saslpay.log.SaslPayLog;
|
||||
import jdk.nashorn.internal.parser.JSONParser;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.util.*;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cbs/get")
|
||||
public class T24DataController {
|
||||
|
||||
List<T24DataEntity> t24DataEntity;
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
AppPropertiesConfig configClass = BeanUtil.getBean(AppPropertiesConfig.class);
|
||||
String t24DataTable = configClass.getT24DataTable();
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImpl = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
|
||||
String sqlStatement;
|
||||
String customerName;
|
||||
String gender;
|
||||
String dob;
|
||||
String emailAddress;
|
||||
String phoneNumber;
|
||||
String branch;
|
||||
String branchName;
|
||||
String identification;
|
||||
String custType;
|
||||
String accountId;
|
||||
String ussdSubscribed;
|
||||
String acStatus = "";
|
||||
String errorMsg = "";
|
||||
String status = "";
|
||||
Float acBalance = 0.00F;
|
||||
|
||||
SaslPayLog saslPayLog = new SaslPayLog();
|
||||
|
||||
@GetMapping(value ="/levycheck/{account}" ,produces = MediaType.APPLICATION_JSON_VALUE )
|
||||
public String getLevy(@PathVariable String account) {
|
||||
return account;
|
||||
|
||||
}
|
||||
|
||||
@GetMapping(value="/accountCustomerDetails/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getAccountCustomer(@PathVariable String account) {
|
||||
saslPayLog.log(account);
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
if (t24DataEntity.isEmpty()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("account", "\"" + account + "\"");
|
||||
object.put("errorMsg" ,"99");
|
||||
object.put("status" , "Customer Does Not Exist");
|
||||
return object + "";
|
||||
}
|
||||
customerName = t24DataEntity.get(0).getCustomerName();
|
||||
dob = t24DataEntity.get(0).getDob();
|
||||
gender = t24DataEntity.get(0).getGender();
|
||||
emailAddress = t24DataEntity.get(0).getEmailAddress();
|
||||
phoneNumber = t24DataEntity.get(0).getPhoneNumber();
|
||||
branch = t24DataEntity.get(0).getBranch();
|
||||
branchName = t24DataEntity.get(0).getBranchName();
|
||||
identification = t24DataEntity.get(0).getCustomerId();
|
||||
custType = t24DataEntity.get(0).getCustomerType();
|
||||
errorMsg = "";
|
||||
status = "00";
|
||||
|
||||
saslPayLog.log("{\"customerDetails\" :[{\"" +
|
||||
"customerName\" :\"" + customerName + "\",\"" +
|
||||
"gender\" :\"" + gender + "\",\"" +
|
||||
"dob\" :\"" + dob + "\",\"" +
|
||||
"phoneNumber\" :\"" + phoneNumber + "\",\"" +
|
||||
"emailAddress\" :\"" + emailAddress + "\",\"" +
|
||||
"branch\" :\"" + branch + "\",\"" +
|
||||
"branchName\" :\"" + branchName + "\",\"" +
|
||||
"identification\" :\"" + identification + "\",\"" +
|
||||
"custType\" :\"" + custType + "\"}],\"" +
|
||||
"status\" :\"" + status + "\",\"" + "errorMsg\" :\"" + errorMsg + "\"" +
|
||||
"}");
|
||||
|
||||
return "{\"customerDetails\" :[{\"" +
|
||||
"customerName\" :\"" + customerName + "\",\"" +
|
||||
"gender\" :\"" + gender + "\",\"" +
|
||||
"dob\" :\"" + dob + "\",\"" +
|
||||
"phoneNumber\" :\"" + phoneNumber + "\",\"" +
|
||||
"emailAddress\" :\"" + emailAddress + "\",\"" +
|
||||
"branch\" :\"" + branch + "\",\"" +
|
||||
"branchName\" :\"" + branchName + "\",\"" +
|
||||
"identification\" :\"" + identification + "\",\"" +
|
||||
"custType\" :\"" + custType + "\"}],\"" +
|
||||
"status\" :\"" + status + "\",\"" + "errorMsg\" :\"" + errorMsg + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@GetMapping(value="/accountList/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getAccountList(@PathVariable String account) {
|
||||
saslPayLog.log(account);
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
if (t24DataEntity.isEmpty()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("account", "\"" + account + "\"");
|
||||
object.put("errorMsg" ,"99");
|
||||
object.put("status" , "Customer Does Not Exist");
|
||||
return object + "";
|
||||
}{
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE customerNo='" + t24DataEntity.get(0).getCustomerNo() + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
}
|
||||
|
||||
// JSONObject object = new JSONObject();
|
||||
JSONArray array = new JSONArray();
|
||||
int arraySize = t24DataEntity.size();
|
||||
int j = 0;
|
||||
for (int i = 0; i < arraySize; i++){
|
||||
ussdSubscribed = t24DataEntity.get(i).getUssdSubscribed();
|
||||
if (ussdSubscribed.equals("Y")){
|
||||
j++;
|
||||
accountId = t24DataEntity.get(i).getAccountId();
|
||||
//object.put( , accountId);
|
||||
//String shit = object.toString();
|
||||
Map m = new LinkedHashMap(1);
|
||||
m.put("account" + j , accountId );
|
||||
array.add(m);
|
||||
//System.out.println(shit);
|
||||
//String shit = object.toString();
|
||||
// object.remove("account" + j);
|
||||
}
|
||||
}
|
||||
|
||||
saslPayLog.log("{\"accountList\": " + array + ", \"status\" : \"00\" , \"errorMsg\" : \"\"}");
|
||||
return "{\"accountList\": " + array + ", \"status\" : \"00\" , \"errorMsg\" : \"\"}";
|
||||
}
|
||||
|
||||
@GetMapping(value="/balance/{account}" , produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getBalance(@PathVariable String account) {
|
||||
saslPayLog.log(account);
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
if (t24DataEntity.isEmpty()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("account", "\"" + account + "\"");
|
||||
object.put("errorMsg" ,"99");
|
||||
object.put("status" , "Account Does Not Exist");
|
||||
return object + "";
|
||||
}
|
||||
customerName = t24DataEntity.get(0).getCustomerName();
|
||||
acBalance = t24DataEntity.get(0).getAccountBalance();
|
||||
acStatus = t24DataEntity.get(0).getAcStatus();
|
||||
if (acStatus.equals("Y")){
|
||||
acStatus = "Inactive Account";
|
||||
} else {
|
||||
acStatus = "";
|
||||
}
|
||||
|
||||
errorMsg = "";
|
||||
status = "00";
|
||||
|
||||
saslPayLog.log("{\"Account\" :\"" + account + "\",\"" +
|
||||
"AcBalance\" :\"" + acBalance + "\",\"" +
|
||||
"AcName\" :\"" + customerName + "\",\"" +
|
||||
"AcStatus\" :\"" + acStatus + "\",\"" +
|
||||
"ErrorMsg\" :\"" + errorMsg + "\",\"" +
|
||||
"Status\" :\"" + status + "\"" +
|
||||
"}");
|
||||
|
||||
return "{\"Account\" :\"" + account + "\",\"" +
|
||||
"AcBalance\" :\"" + acBalance + "\",\"" +
|
||||
"AcName\" :\"" + customerName + "\",\"" +
|
||||
"AcStatus\" :\"" + acStatus + "\",\"" +
|
||||
"ErrorMsg\" :\"" + errorMsg + "\",\"" +
|
||||
"Status\" :\"" + status + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@GetMapping(value="/customerDetails/{customerNo}" , produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String getCustomerDetails(@PathVariable String customerNo) {
|
||||
saslPayLog.log(customerNo);
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE customerNo='" + customerNo + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
if (t24DataEntity.isEmpty()){
|
||||
JSONObject object = new JSONObject();
|
||||
object.put("account", "\"" + customerNo + "\"");
|
||||
object.put("errorMsg" ,"99");
|
||||
object.put("status" , "Customer Does Not Exist");
|
||||
return object + "";
|
||||
}
|
||||
customerName = t24DataEntity.get(0).getCustomerName();
|
||||
dob = t24DataEntity.get(0).getDob();
|
||||
gender = t24DataEntity.get(0).getGender();
|
||||
emailAddress = t24DataEntity.get(0).getEmailAddress();
|
||||
phoneNumber = t24DataEntity.get(0).getPhoneNumber();
|
||||
branch = t24DataEntity.get(0).getBranch();
|
||||
branchName = t24DataEntity.get(0).getBranchName();
|
||||
identification = t24DataEntity.get(0).getCustomerId();
|
||||
custType = t24DataEntity.get(0).getCustomerType();
|
||||
errorMsg = "";
|
||||
status = "00";
|
||||
|
||||
saslPayLog.log("{\"customerDetails\" :[{\"" +
|
||||
"customerName\" :\"" + customerName + "\",\"" +
|
||||
"gender\" :\"" + gender + "\",\"" +
|
||||
"dob\" :\"" + dob + "\",\"" +
|
||||
"phoneNumber\" :\"" + phoneNumber + "\",\"" +
|
||||
"emailAddress\" :\"" + emailAddress + "\",\"" +
|
||||
"branch\" :\"" + branch + "\",\"" +
|
||||
"branchName\" :\"" + branchName + "\",\"" +
|
||||
"identification\" :\"" + identification + "\",\"" +
|
||||
"custType\" :\"" + custType + "\"}],\"" +
|
||||
"status\" :\"" + status + "\",\"" + "errorMsg\" :\"" + errorMsg + "\"" +
|
||||
"}");
|
||||
|
||||
return "{\"customerDetails\" :[{\"" +
|
||||
"customerName\" :\"" + customerName + "\",\"" +
|
||||
"gender\" :\"" + gender + "\",\"" +
|
||||
"dob\" :\"" + dob + "\",\"" +
|
||||
"phoneNumber\" :\"" + phoneNumber + "\",\"" +
|
||||
"emailAddress\" :\"" + emailAddress + "\",\"" +
|
||||
"branch\" :\"" + branch + "\",\"" +
|
||||
"branchName\" :\"" + branchName + "\",\"" +
|
||||
"identification\" :\"" + identification + "\",\"" +
|
||||
"custType\" :\"" + custType + "\"}],\"" +
|
||||
"status\" :\"" + status + "\",\"" + "errorMsg\" :\"" + errorMsg + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
||||
@GetMapping(value = "/allAccounts", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public List<T24DataEntity> getAll() {
|
||||
// saslPayLog.log("Requst All Accounts");
|
||||
// t24DataEntity = t24DataServiceImpl.findAll();
|
||||
// saslPayLog.log(t24DataEntity.toString());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
//"{\"txnCode\" :\"" + txnCode + "\",\"" +
|
||||
// "api\" :\"" + api + "\",\"" +
|
||||
// "requestType\" :\"" + requestType + "\",\"" +
|
||||
// "otherTxnRef\" :\"" + txnRef + "\",\"" +
|
||||
// "drAccount\" :\"" + drAccount + "\",\"" +
|
||||
// "crAccount\" :\"" + crAccount + "\",\"" +
|
||||
// "ourTxnRef\" :\"" + "" + "\",\"" +
|
||||
// "errorMsg\" :\"" + error + "\",\"" +
|
||||
// "status\" :\"" + status + "\"" +
|
||||
// "}";
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.saslpay.controller;
|
||||
|
||||
import com.saslpay.datacapture.*;
|
||||
import com.saslpay.log.SaslPayLog;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/cbs/post")
|
||||
public class TransactionDataController {
|
||||
|
||||
SaslPayLog saslPayLog = new SaslPayLog();
|
||||
|
||||
@PostMapping(value = "/exttransfer", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String postExtTxn(@RequestBody String request) throws IOException {
|
||||
saslPayLog.log(request);
|
||||
ExtTransferCapture extTransferCapture = new ExtTransferCapture();
|
||||
String response = extTransferCapture.extTransfer(request);
|
||||
saslPayLog.log(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/inttransfer", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String postIntTxn(@RequestBody String request) throws IOException {
|
||||
saslPayLog.log(request);
|
||||
IntTransferCapture intTransferCapture = new IntTransferCapture();
|
||||
String response = intTransferCapture.intTransfer(request);
|
||||
saslPayLog.log(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/extreversal", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String postExtRev(@RequestBody String request) throws IOException {
|
||||
saslPayLog.log(request);
|
||||
ExtReversalCapture extReversalrCapture = new ExtReversalCapture();
|
||||
String response = extReversalrCapture.extReversal(request);
|
||||
saslPayLog.log(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/intreversal", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String postIntRev(@RequestBody String request) throws IOException {
|
||||
saslPayLog.log(request);
|
||||
IntReversalCapture intReversalCapture = new IntReversalCapture();
|
||||
String response = intReversalCapture.intReversal(request);
|
||||
saslPayLog.log(response);
|
||||
return response;
|
||||
}
|
||||
|
||||
@PostMapping(value = "/levyCharge", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String postLevyCharge(@RequestBody String request) throws IOException {
|
||||
saslPayLog.log(request);
|
||||
LevyPay levyPay = new LevyPay();
|
||||
String response = levyPay.levyPay(request);
|
||||
saslPayLog.log(response);
|
||||
return response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.sql.Date;
|
||||
|
||||
//@Component
|
||||
public class AccountDataCapture {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImpl;
|
||||
|
||||
T24DataEntity t24DataEntity = new T24DataEntity();
|
||||
|
||||
public void importer(String body){
|
||||
|
||||
t24DataServiceImpl = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
String accountId = StringUtils.substringBetween(body,"<accountId>","</accountId>");
|
||||
String category = StringUtils.substringBetween(body,"<category>","</category>");
|
||||
String customerNo = StringUtils.substringBetween(body,"<customerNo>","</customerNo>");
|
||||
String customerName = StringUtils.substringBetween(body,"<customerName>","</customerName>");
|
||||
String customerType = StringUtils.substringBetween(body,"<customerType>","</customerType>");
|
||||
String customerId = StringUtils.substringBetween(body,"<customerId>","</customerId>");
|
||||
String phoneNumber = StringUtils.substringBetween(body,"<phoneNumber>","</phoneNumber>");
|
||||
String branch = StringUtils.substringBetween(body,"<branch>","</branch>");
|
||||
String branchName = StringUtils.substringBetween(body,"<branchName>","</branchName>");
|
||||
String dob = StringUtils.substringBetween(body,"<dob>","</dob>");
|
||||
String emailAddress = StringUtils.substringBetween(body,"<emailAddress>","</emailAddress>");
|
||||
String gender = StringUtils.substringBetween(body,"<gender>","</gender>");
|
||||
String acStatus = StringUtils.substringBetween(body,"<acStatus>","</acStatus>");
|
||||
String accountBalance = StringUtils.substringBetween(body,"<accountBalance>","</accountBalance>");
|
||||
String maxCreditBalance = StringUtils.substringBetween(body,"<maxCreditBalance>","</maxCreditBalance>");
|
||||
String maxDebitBalance = StringUtils.substringBetween(body,"<maxDebitBalance>","</maxDebitBalance>");
|
||||
String debitAllowed = StringUtils.substringBetween(body,"<debitAllowed>","</debitAllowed>");
|
||||
String creditAllowed = StringUtils.substringBetween(body,"<creditAllowed>","</creditAllowed>");
|
||||
String ussdSubscribed = StringUtils.substringBetween(body,"<ussdSubscribed>","</ussdSubscribed>");
|
||||
|
||||
t24DataEntity.setAccountId(accountId);
|
||||
t24DataEntity.setCategory(category);
|
||||
t24DataEntity.setCustomerNo(customerNo);
|
||||
t24DataEntity.setCustomerName(customerName);
|
||||
t24DataEntity.setCustomerType(customerType);
|
||||
t24DataEntity.setCustomerId(customerId);
|
||||
t24DataEntity.setPhoneNumber(phoneNumber);
|
||||
t24DataEntity.setBranch(branch);
|
||||
t24DataEntity.setBranchName(branchName);
|
||||
t24DataEntity.setDob(dob);
|
||||
t24DataEntity.setEmailAddress(emailAddress);
|
||||
t24DataEntity.setGender(gender);
|
||||
t24DataEntity.setAcStatus(acStatus);
|
||||
t24DataEntity.setAccountBalance(Float.valueOf(accountBalance));
|
||||
t24DataEntity.setMaxCreditBalance(Float.valueOf(maxCreditBalance));
|
||||
t24DataEntity.setMaxDebitBalance(Float.valueOf(maxDebitBalance));
|
||||
t24DataEntity.setDebitAllowed(debitAllowed);
|
||||
t24DataEntity.setCreditAllowed(creditAllowed);
|
||||
t24DataEntity.setUssdSubscribed(ussdSubscribed);
|
||||
t24DataServiceImpl.save(t24DataEntity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,399 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.saslpay.config.AppPropertiesConfig;
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import com.saslpay.impl.TransactionDataServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.aspectj.util.LangUtil.isEmpty;
|
||||
|
||||
public class ExtReversalCapture {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDataServiceImpl transactionDataServiceImpl;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImpl;
|
||||
|
||||
TransactionDataEntity transactionDataEntitySave = new TransactionDataEntity();
|
||||
T24DataEntity t24DataEntitySave = new T24DataEntity();
|
||||
List<TransactionDataEntity> transactionDataEntity;
|
||||
List<T24DataEntity> t24DataEntity;
|
||||
|
||||
AppPropertiesConfig configClass = BeanUtil.getBean(AppPropertiesConfig.class);
|
||||
String t24DataTable = configClass.getT24DataTable();
|
||||
String transactionDataTable = configClass.getTransactionDataTable();
|
||||
String outFolder = configClass.getOutFolder();
|
||||
|
||||
String sqlStatement;
|
||||
String errorMessage;
|
||||
String txnCode;
|
||||
String hold;
|
||||
String bankWallet;
|
||||
String customerName;
|
||||
String customerBranch;
|
||||
String drAccount;
|
||||
String crAccount;
|
||||
String txnCurrency;
|
||||
String txnAmount;
|
||||
String txnCharge;
|
||||
String txnNarration;
|
||||
String api;
|
||||
String requestType;
|
||||
String txnRef;
|
||||
String ftRef;
|
||||
String errorMsg;
|
||||
String statusMsg;
|
||||
String txnStatus = "";
|
||||
String account;
|
||||
Float sumBalance = 0.0F;
|
||||
Float newBalance = 0.0F;
|
||||
Float acBalance = 0.0F;
|
||||
Float fullAmt;
|
||||
|
||||
// @PostMapping(value ="/extreversal" ,produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
public String extReversal(String request) throws IOException {
|
||||
|
||||
JsonElement jsonElementAuth = JsonParser.parseString(request);
|
||||
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
|
||||
transactionDataServiceImpl = BeanUtil.getBean(TransactionDataServiceImpl.class);
|
||||
t24DataServiceImpl = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
|
||||
try {
|
||||
txnCode = jsonObjectAuth.get("txnCode").getAsString();
|
||||
api = jsonObjectAuth.get("api").getAsString();
|
||||
requestType = jsonObjectAuth.get("requestType").getAsString();
|
||||
ftRef = jsonObjectAuth.get("ourTxnRef").getAsString();
|
||||
txnRef = jsonObjectAuth.get("otherTxnRef").getAsString();
|
||||
hold = jsonObjectAuth.get("hold").getAsString();
|
||||
bankWallet = jsonObjectAuth.get("bankWallet").getAsString();
|
||||
customerName = jsonObjectAuth.get("customerName").getAsString();
|
||||
customerBranch = jsonObjectAuth.get("customerBranch").getAsString();
|
||||
drAccount = jsonObjectAuth.get("drAccount").getAsString();
|
||||
crAccount = jsonObjectAuth.get("crAccount").getAsString();
|
||||
txnCurrency = jsonObjectAuth.get("txnCurrency").getAsString();
|
||||
txnAmount = jsonObjectAuth.get("txnAmount").getAsString();
|
||||
txnCharge = jsonObjectAuth.get("txnCharge").getAsString();
|
||||
txnNarration = jsonObjectAuth.get("txnNarration").getAsString();
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
errorMessage = e.getLocalizedMessage();
|
||||
}
|
||||
|
||||
if (txnRef.isEmpty()){
|
||||
errorMsg = "Payment Reference Empty";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
String transactionDataQuery = "SELECT * FROM " + transactionDataTable + " WHERE txnRef='" + txnRef + "'";
|
||||
transactionDataEntity = entityManager.createNativeQuery(transactionDataQuery, TransactionDataEntity.class).getResultList();
|
||||
boolean isTxnEmpty = isEmpty(transactionDataEntity);
|
||||
if (isTxnEmpty){
|
||||
errorMsg = "Payment Reference Invalid - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
crAccount = transactionDataEntity.get(0).getCrAccount();
|
||||
drAccount = transactionDataEntity.get(0).getDrAccount();
|
||||
txnCode = transactionDataEntity.get(0).getTxnCode();
|
||||
api = transactionDataEntity.get(0).getApi();
|
||||
requestType = transactionDataEntity.get(0).getRequestType();
|
||||
|
||||
switch (txnCode){
|
||||
case "extDebTrf":
|
||||
account = drAccount;
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isDebEmpty = isEmpty(t24DataEntity);
|
||||
if (isDebEmpty){
|
||||
errorMsg = "Debit Account Number - " + drAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
fullAmt = transactionDataEntity.get(0).getTxnAmount() + transactionDataEntity.get(0).getTxnCharge();
|
||||
acBalance = t24DataEntity.get(0).getAccountBalance();
|
||||
newBalance = fullAmt + acBalance ;
|
||||
break;
|
||||
case "extCredTrf":
|
||||
account = crAccount;
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isCreEmpty = isEmpty(t24DataEntity);
|
||||
if (isCreEmpty){
|
||||
errorMsg = "Credit Account Number - " + crAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
fullAmt = transactionDataEntity.get(0).getTxnAmount() + transactionDataEntity.get(0).getTxnCharge();
|
||||
acBalance = t24DataEntity.get(0).getAccountBalance();
|
||||
newBalance = acBalance - fullAmt;
|
||||
break;
|
||||
}
|
||||
|
||||
txnStatus = transactionDataEntity.get(0).getTxnStatus();
|
||||
switch (hold){
|
||||
case "F":
|
||||
|
||||
if(txnStatus.equals("hold")){
|
||||
errorMsg = "Cannot Reverse Transaction in hold - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("del")){
|
||||
errorMsg = "Transaction Deleted - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("rev")){
|
||||
errorMsg = "Transaction Already Reversed! - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("revch")){
|
||||
errorMsg = "Charge Already Reversed, Can Only reverse Amount- " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("revamt")){
|
||||
errorMsg = "Amount Already Reversed, Can Only reverse Charge - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(transactionDataEntity.get(0).getApi());
|
||||
transactionDataEntitySave.setHold(hold);
|
||||
transactionDataEntitySave.setRequestType(transactionDataEntity.get(0).getRequestType());
|
||||
transactionDataEntitySave.setFtId(transactionDataEntity.get(0).getFtId());
|
||||
transactionDataEntitySave.setTxnCode(transactionDataEntity.get(0).getTxnCode());
|
||||
transactionDataEntitySave.setBankWallet(transactionDataEntity.get(0).getBankWallet());
|
||||
transactionDataEntitySave.setCustomerBranch(transactionDataEntity.get(0).getCustomerBranch());
|
||||
transactionDataEntitySave.setDrAccount(transactionDataEntity.get(0).getDrAccount());
|
||||
transactionDataEntitySave.setCrAccount(transactionDataEntity.get(0).getCrAccount());
|
||||
transactionDataEntitySave.setTxnAmount(transactionDataEntity.get(0).getTxnAmount());
|
||||
transactionDataEntitySave.setTxnCharge(transactionDataEntity.get(0).getTxnCharge());
|
||||
transactionDataEntitySave.setTxnCurrency(transactionDataEntity.get(0).getTxnCurrency());
|
||||
transactionDataEntitySave.setTxnNarration(transactionDataEntity.get(0).getTxnNarration());
|
||||
transactionDataEntitySave.setTxnStatus("rev");
|
||||
transactionDataEntitySave.setProcessFlag("Y");
|
||||
transactionDataEntitySave.setElevyCharge(transactionDataEntity.get(0).getElevyCharge());
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(newBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImpl.save(t24DataEntitySave);
|
||||
|
||||
break;
|
||||
|
||||
case "A":
|
||||
|
||||
if(txnStatus.equals("hold")){
|
||||
errorMsg = "Cannot Reverse Transaction in hold - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("del")){
|
||||
errorMsg = "Transaction Deleted - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("rev")){
|
||||
errorMsg = "Transaction Already Reversed! - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("revamt")){
|
||||
errorMsg = "Amount Already Reversed, Can Only reverse Charge - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(transactionDataEntity.get(0).getApi());
|
||||
transactionDataEntitySave.setHold(hold);
|
||||
transactionDataEntitySave.setRequestType(transactionDataEntity.get(0).getRequestType());
|
||||
transactionDataEntitySave.setFtId(transactionDataEntity.get(0).getFtId());
|
||||
transactionDataEntitySave.setTxnCode(transactionDataEntity.get(0).getTxnCode());
|
||||
transactionDataEntitySave.setBankWallet(transactionDataEntity.get(0).getBankWallet());
|
||||
transactionDataEntitySave.setCustomerName(transactionDataEntity.get(0).getCustomerName());
|
||||
transactionDataEntitySave.setCustomerBranch(transactionDataEntity.get(0).getCustomerBranch());
|
||||
transactionDataEntitySave.setDrAccount(transactionDataEntity.get(0).getDrAccount());
|
||||
transactionDataEntitySave.setCrAccount(transactionDataEntity.get(0).getCrAccount());
|
||||
transactionDataEntitySave.setTxnAmount(transactionDataEntity.get(0).getTxnAmount());
|
||||
transactionDataEntitySave.setTxnCharge(transactionDataEntity.get(0).getTxnCharge());
|
||||
transactionDataEntitySave.setTxnCurrency(transactionDataEntity.get(0).getTxnCurrency());
|
||||
transactionDataEntitySave.setTxnNarration(transactionDataEntity.get(0).getTxnNarration());
|
||||
transactionDataEntitySave.setTxnStatus("revamt");
|
||||
transactionDataEntitySave.setProcessFlag("Y");
|
||||
transactionDataEntitySave.setElevyCharge(transactionDataEntity.get(0).getElevyCharge());
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(newBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImpl.save(t24DataEntitySave);
|
||||
|
||||
break;
|
||||
case "C":
|
||||
|
||||
if(txnStatus.equals("hold")){
|
||||
errorMsg = "Cannot Reverse Transaction in hold - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("del")){
|
||||
errorMsg = "Transaction Deleted - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
|
||||
if(txnStatus.equals("rev")){
|
||||
errorMsg = "Transaction Already Reversed! - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if(txnStatus.equals("revchg")){
|
||||
errorMsg = "Charge Already Reversed, Can Only reverse Amount- " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(transactionDataEntity.get(0).getApi());
|
||||
transactionDataEntitySave.setHold(hold);
|
||||
transactionDataEntitySave.setRequestType(transactionDataEntity.get(0).getRequestType());
|
||||
transactionDataEntitySave.setFtId(ftRef);
|
||||
transactionDataEntitySave.setTxnCode(transactionDataEntity.get(0).getTxnCode());
|
||||
transactionDataEntitySave.setBankWallet(transactionDataEntity.get(0).getBankWallet());
|
||||
transactionDataEntitySave.setCustomerName(transactionDataEntity.get(0).getCustomerName());
|
||||
transactionDataEntitySave.setCustomerBranch(transactionDataEntity.get(0).getCustomerBranch());
|
||||
transactionDataEntitySave.setDrAccount(transactionDataEntity.get(0).getDrAccount());
|
||||
transactionDataEntitySave.setCrAccount(transactionDataEntity.get(0).getCrAccount());
|
||||
transactionDataEntitySave.setTxnAmount(transactionDataEntity.get(0).getTxnAmount());
|
||||
transactionDataEntitySave.setTxnCharge(transactionDataEntity.get(0).getTxnCharge());
|
||||
transactionDataEntitySave.setTxnCurrency(transactionDataEntity.get(0).getTxnCurrency());
|
||||
transactionDataEntitySave.setTxnNarration(transactionDataEntity.get(0).getTxnNarration());
|
||||
transactionDataEntitySave.setTxnStatus("revchg");
|
||||
transactionDataEntitySave.setProcessFlag("Y");
|
||||
transactionDataEntitySave.setElevyCharge(transactionDataEntity.get(0).getElevyCharge());
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(acBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImpl.save(t24DataEntitySave);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
errorMsg = "Invalid Option";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
errorMsg = "";
|
||||
statusMsg = "00";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
// public void txnWriter(String outRequest) throws IOException {
|
||||
// FileWriter myWriter = new FileWriter(outFolder + "/"+ txnRef + ".xml");
|
||||
// myWriter.write(outRequest);
|
||||
// myWriter.close();
|
||||
// }
|
||||
|
||||
public String outValue(String api, String txnCode, String requestType, String drAccount, String crAccount, String txnRef, String error, String status){
|
||||
|
||||
return "{\"txnCode\" :\"" + txnCode + "\",\"" +
|
||||
"api\" :\"" + api + "\",\"" +
|
||||
"requestType\" :\"" + requestType + "\",\"" +
|
||||
"otherTxnRef\" :\"" + txnRef + "\",\"" +
|
||||
"drAccount\" :\"" + drAccount + "\",\"" +
|
||||
"crAccount\" :\"" + crAccount + "\",\"" +
|
||||
"ourTxnRef\" :\"" + "" + "\",\"" +
|
||||
"errorMsg\" :\"" + error + "\",\"" +
|
||||
"status\" :\"" + status + "\"" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,452 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.saslpay.config.AppPropertiesConfig;
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import com.saslpay.impl.TransactionDataServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.aspectj.util.LangUtil.isEmpty;
|
||||
|
||||
public class ExtTransferCapture {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDataServiceImpl transactionDataServiceImpl;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImpl;
|
||||
|
||||
TransactionDataEntity transactionDataEntitySave = new TransactionDataEntity();
|
||||
T24DataEntity t24DataEntitySave = new T24DataEntity();
|
||||
List<TransactionDataEntity> transactionDataEntity;
|
||||
List<T24DataEntity> t24DataEntity;
|
||||
|
||||
AppPropertiesConfig configClass = BeanUtil.getBean(AppPropertiesConfig.class);
|
||||
String t24DataTable = configClass.getT24DataTable();
|
||||
String transactionDataTable = configClass.getTransactionDataTable();
|
||||
String outFolder = configClass.getOutFolder();
|
||||
String sqlStatement;
|
||||
String account;
|
||||
String errorMessage;
|
||||
String txnCode;
|
||||
String txnRef;
|
||||
String ftRef;
|
||||
String hold;
|
||||
String bankWallet;
|
||||
String customerName;
|
||||
String customerBranch;
|
||||
String drAccount;
|
||||
String crAccount;
|
||||
String txnCurrency;
|
||||
String txnAmount;
|
||||
String txnCharge;
|
||||
String txnNarration;
|
||||
String api;
|
||||
String requestType;
|
||||
String elevyCharge;
|
||||
String readRef = "";
|
||||
String txnStatus = "";
|
||||
String errorMsg;
|
||||
String statusMsg;
|
||||
Float sumBalance = 0.00F;
|
||||
Float newBalance = 0.0F;
|
||||
Float minBalance = 0.0F;
|
||||
Float maxBalance = 0.0F;
|
||||
Float acBalance = 0.0F;
|
||||
|
||||
public String extTransfer(String request) throws IOException {
|
||||
|
||||
JsonElement jsonElementAuth = JsonParser.parseString(request);
|
||||
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
|
||||
transactionDataServiceImpl = BeanUtil.getBean(TransactionDataServiceImpl.class);
|
||||
t24DataServiceImpl = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
try {
|
||||
txnCode = jsonObjectAuth.get("txnCode").getAsString();
|
||||
api = jsonObjectAuth.get("api").getAsString();
|
||||
requestType = jsonObjectAuth.get("requestType").getAsString();
|
||||
ftRef = jsonObjectAuth.get("ourTxnRef").getAsString();
|
||||
txnRef = jsonObjectAuth.get("otherTxnRef").getAsString();
|
||||
hold = jsonObjectAuth.get("hold").getAsString();
|
||||
bankWallet = jsonObjectAuth.get("bankWallet").getAsString();
|
||||
customerName = jsonObjectAuth.get("customerName").getAsString();
|
||||
customerBranch = jsonObjectAuth.get("customerBranch").getAsString();
|
||||
drAccount = jsonObjectAuth.get("drAccount").getAsString();
|
||||
crAccount = jsonObjectAuth.get("crAccount").getAsString();
|
||||
txnCurrency = jsonObjectAuth.get("txnCurrency").getAsString();
|
||||
txnAmount = jsonObjectAuth.get("txnAmount").getAsString();
|
||||
txnCharge = jsonObjectAuth.get("txnCharge").getAsString();
|
||||
txnNarration = jsonObjectAuth.get("txnNarration").getAsString();
|
||||
elevyCharge = jsonObjectAuth.get("elevyCharge").getAsString();
|
||||
sumBalance = Float.parseFloat(txnAmount) + Float.parseFloat(txnCharge) + Float.parseFloat(elevyCharge);
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
errorMessage = e.getLocalizedMessage();
|
||||
}
|
||||
|
||||
if (txnRef.isEmpty()){
|
||||
errorMsg = "Payment Reference Empty";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
if (drAccount.equals(crAccount)) {
|
||||
errorMsg = "Cannot Debit and Credit Same Account Number";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
switch (txnCode){
|
||||
case "extDebTrf":
|
||||
account = drAccount;
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isDebEmpty = isEmpty(t24DataEntity);
|
||||
if (isDebEmpty){
|
||||
errorMsg = "Debit Account Number - " + drAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
String debitAllowed = t24DataEntity.get(0).getDebitAllowed();
|
||||
if (debitAllowed.equals("N")) {
|
||||
errorMsg = drAccount + " - Customer Account - Is not allowed to Send Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
String inactiveMarker = t24DataEntity.get(0).getAcStatus();
|
||||
if (inactiveMarker.equals("Y")) {
|
||||
errorMsg = "Account Number - " + drAccount + " is Inactive";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
minBalance = t24DataEntity.get(0).getMaxDebitBalance();
|
||||
maxBalance = t24DataEntity.get(0).getMaxCreditBalance();
|
||||
acBalance = t24DataEntity.get(0).getAccountBalance();
|
||||
|
||||
if (sumBalance > acBalance){
|
||||
errorMsg = "Account Number - " +drAccount + " has Insufficient Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
Float balanceDifference = acBalance - sumBalance;
|
||||
if(minBalance > balanceDifference){
|
||||
errorMsg = "Debit Exceeds Minimum Balance";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
if (sumBalance > maxBalance){
|
||||
errorMsg = "Transaction Amount Exceeds Maximum Transaction Limit";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
newBalance = balanceDifference;
|
||||
break;
|
||||
case "extCredTrf":
|
||||
account = crAccount;
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isCreEmpty = isEmpty(t24DataEntity);
|
||||
if (isCreEmpty){
|
||||
errorMsg = "Credit Account Number - " + crAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
String creditAllowed = t24DataEntity.get(0).getCreditAllowed();
|
||||
if (creditAllowed.equals("N")) {
|
||||
errorMsg = crAccount + " - Customer Account - Is not allowed to Recieve Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
acBalance = t24DataEntity.get(0).getAccountBalance();
|
||||
newBalance = acBalance + sumBalance;
|
||||
break;
|
||||
}
|
||||
|
||||
String transactionDataQuery = "SELECT * FROM " + transactionDataTable + " WHERE txnRef='" + txnRef + "'";
|
||||
transactionDataEntity = entityManager.createNativeQuery(transactionDataQuery,TransactionDataEntity.class).getResultList();
|
||||
boolean isTxnEmpty = isEmpty(transactionDataEntity);
|
||||
if (isTxnEmpty){
|
||||
readRef = "";
|
||||
txnStatus = "";
|
||||
} else {
|
||||
readRef = transactionDataEntity.get(0).getTxnRef();
|
||||
txnStatus = transactionDataEntity.get(0).getTxnStatus();
|
||||
}
|
||||
|
||||
String newRef = geFundsTransferRef();
|
||||
|
||||
switch (hold){
|
||||
case "":
|
||||
|
||||
if (readRef.isEmpty()) {
|
||||
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(api);
|
||||
transactionDataEntitySave.setHold(hold);
|
||||
transactionDataEntitySave.setRequestType(requestType);
|
||||
transactionDataEntitySave.setFtId(newRef);
|
||||
transactionDataEntitySave.setTxnCode(txnCode);
|
||||
transactionDataEntitySave.setBankWallet(bankWallet);
|
||||
transactionDataEntitySave.setCustomerName(customerName);
|
||||
transactionDataEntitySave.setCustomerBranch(customerBranch);
|
||||
transactionDataEntitySave.setDrAccount(drAccount);
|
||||
transactionDataEntitySave.setCrAccount(crAccount);
|
||||
transactionDataEntitySave.setTxnAmount(Float.parseFloat(txnAmount));
|
||||
transactionDataEntitySave.setElevyCharge(Float.parseFloat(elevyCharge));
|
||||
transactionDataEntitySave.setTxnCharge(Float.parseFloat(txnCharge));
|
||||
transactionDataEntitySave.setTxnCurrency(txnCurrency);
|
||||
transactionDataEntitySave.setTxnNarration(txnNarration);
|
||||
transactionDataEntitySave.setTxnStatus("auth");
|
||||
transactionDataEntitySave.setTransactionType("extTransfer");
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(newBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImpl.save(t24DataEntitySave);
|
||||
ftRef = newRef;
|
||||
// txnWriter(request);
|
||||
} else {
|
||||
errorMsg = "Duplicate Transaction - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
break;
|
||||
|
||||
case "H":
|
||||
|
||||
if (readRef.isEmpty()){
|
||||
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(api);
|
||||
transactionDataEntitySave.setHold(hold);
|
||||
transactionDataEntitySave.setRequestType(requestType);
|
||||
transactionDataEntitySave.setFtId(newRef);
|
||||
transactionDataEntitySave.setTxnCode(txnCode);
|
||||
transactionDataEntitySave.setBankWallet(bankWallet);
|
||||
transactionDataEntitySave.setCustomerName(customerName);
|
||||
transactionDataEntitySave.setCustomerBranch(customerBranch);
|
||||
transactionDataEntitySave.setDrAccount(drAccount);
|
||||
transactionDataEntitySave.setCrAccount(crAccount);
|
||||
transactionDataEntitySave.setTxnAmount(Float.parseFloat(txnAmount));
|
||||
transactionDataEntitySave.setElevyCharge(Float.parseFloat(elevyCharge));
|
||||
transactionDataEntitySave.setTxnCharge(Float.parseFloat(txnCharge));
|
||||
transactionDataEntitySave.setTxnCurrency(txnCurrency);
|
||||
transactionDataEntitySave.setTxnNarration(txnNarration);
|
||||
transactionDataEntitySave.setTxnStatus("hold");
|
||||
transactionDataEntitySave.setTransactionType("extTransfer");
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(newBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImpl.save(t24DataEntitySave);
|
||||
ftRef = newRef;
|
||||
} else {
|
||||
errorMsg = "Duplicate Transaction - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
break;
|
||||
case "D":
|
||||
|
||||
if (txnStatus.equals("del")) {
|
||||
errorMsg = "Unauthorised Record Doesnt exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
if (txnStatus.equals("auth")) {
|
||||
errorMsg = "Unauthorised Record Doesnt exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
if (txnStatus.equals("hold")) {
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(api);
|
||||
transactionDataEntitySave.setHold(hold);
|
||||
transactionDataEntitySave.setRequestType(requestType);
|
||||
transactionDataEntitySave.setFtId(ftRef);
|
||||
transactionDataEntitySave.setTxnCode(txnCode);
|
||||
transactionDataEntitySave.setBankWallet(bankWallet);
|
||||
transactionDataEntitySave.setCustomerName(customerName);
|
||||
transactionDataEntitySave.setCustomerBranch(customerBranch);
|
||||
transactionDataEntitySave.setDrAccount(drAccount);
|
||||
transactionDataEntitySave.setCrAccount(crAccount);
|
||||
transactionDataEntitySave.setTxnAmount(Float.parseFloat(txnAmount));
|
||||
transactionDataEntitySave.setElevyCharge(Float.parseFloat(elevyCharge));
|
||||
transactionDataEntitySave.setTxnCharge(Float.parseFloat(txnCharge));
|
||||
transactionDataEntitySave.setTxnCurrency(txnCurrency);
|
||||
transactionDataEntitySave.setTxnNarration(txnNarration);
|
||||
transactionDataEntitySave.setTxnStatus("del");
|
||||
transactionDataEntitySave.setProcessFlag("Y");
|
||||
transactionDataEntitySave.setTransactionType("extTransfer");
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(acBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImpl.save(t24DataEntitySave);
|
||||
|
||||
} else {
|
||||
errorMsg = drAccount + " - Customer Account - Is not allowed to Send Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
break;
|
||||
|
||||
case "A":
|
||||
|
||||
if (txnStatus.equals("del")) {
|
||||
errorMsg = "Unauthorised Record Doesnt exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
if (txnStatus.equals("auth")) {
|
||||
errorMsg = "Unauthorised Record Doesnt exist";
|
||||
statusMsg = "99";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
if (txnStatus.equals("hold")) {
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi(api);
|
||||
transactionDataEntitySave.setHold("");
|
||||
transactionDataEntitySave.setRequestType(requestType);
|
||||
transactionDataEntitySave.setFtId(ftRef);
|
||||
transactionDataEntitySave.setTxnCode(txnCode);
|
||||
transactionDataEntitySave.setBankWallet(bankWallet);
|
||||
transactionDataEntitySave.setCustomerName(customerName);
|
||||
transactionDataEntitySave.setCustomerBranch(customerBranch);
|
||||
transactionDataEntitySave.setDrAccount(drAccount);
|
||||
transactionDataEntitySave.setCrAccount(crAccount);
|
||||
transactionDataEntitySave.setTxnAmount(Float.parseFloat(txnAmount));
|
||||
transactionDataEntitySave.setElevyCharge(Float.parseFloat(elevyCharge));
|
||||
transactionDataEntitySave.setTxnCharge(Float.parseFloat(txnCharge));
|
||||
transactionDataEntitySave.setTxnCurrency(txnCurrency);
|
||||
transactionDataEntitySave.setTxnNarration(txnNarration);
|
||||
transactionDataEntitySave.setTxnStatus("auth");
|
||||
transactionDataEntitySave.setTransactionType("extTransfer");
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
// txnWriter(request);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
errorMsg = "";
|
||||
statusMsg = "00";
|
||||
return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg, ftRef);
|
||||
}
|
||||
|
||||
// public void txnWriter(String outRequest) throws IOException {
|
||||
// FileWriter myWriter = new FileWriter(outFolder + "/"+ txnRef + ".xml");
|
||||
// myWriter.write(outRequest);
|
||||
// myWriter.close();
|
||||
// }
|
||||
|
||||
public String outValue(String api, String txnCode, String requestType, String drAccount, String crAccount, String txnRef, String error, String status, String ftRef){
|
||||
|
||||
return "{\"txnCode\" :\"" + txnCode + "\",\"" +
|
||||
"api\" :\"" + api + "\",\"" +
|
||||
"requestType\" :\"" + requestType + "\",\"" +
|
||||
"otherTxnRef\" :\"" + txnRef + "\",\"" +
|
||||
"drAccount\" :\"" + drAccount + "\",\"" +
|
||||
"crAccount\" :\"" + crAccount + "\",\"" +
|
||||
"ourTxnRef\" :\"" + ftRef + "\",\"" +
|
||||
"errorMsg\" :\"" + error + "\",\"" +
|
||||
"status\" :\"" + status + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
||||
public String geFundsTransferRef() {
|
||||
int leftLimit = 48; // numeral '0'
|
||||
int rightLimit = 122; // letter 'z'
|
||||
int targetStringLength = 6;
|
||||
Random random = new Random();
|
||||
int day = LocalDate.now().getDayOfYear();
|
||||
String year = String.valueOf(LocalDate.now()).substring(2, 4);
|
||||
String paddedString = StringUtils.leftPad(String.valueOf(day), 3, "0");
|
||||
String generatedString = random.ints(leftLimit, rightLimit + 1)
|
||||
.filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
|
||||
.limit(targetStringLength)
|
||||
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
|
||||
.toString();
|
||||
return "FT" + year + paddedString + generatedString.toUpperCase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,232 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.saslpay.config.AppPropertiesConfig;
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import com.saslpay.impl.TransactionDataServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.aspectj.util.LangUtil.isEmpty;
|
||||
|
||||
public class IntReversalCapture {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDataServiceImpl transactionDataServiceImpl;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImpl;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImplCr;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImplDr;
|
||||
|
||||
TransactionDataEntity transactionDataEntitySave = new TransactionDataEntity();
|
||||
T24DataEntity t24DataEntitySaveCr = new T24DataEntity();
|
||||
T24DataEntity t24DataEntitySaveDr = new T24DataEntity();
|
||||
List<TransactionDataEntity> transactionDataEntity;
|
||||
List<T24DataEntity> t24DataEntityCr;
|
||||
List<T24DataEntity> t24DataEntityDr;
|
||||
|
||||
AppPropertiesConfig configClass = BeanUtil.getBean(AppPropertiesConfig.class);
|
||||
String t24DataTable = configClass.getT24DataTable();
|
||||
String transactionDataTable = configClass.getTransactionDataTable();
|
||||
String outFolder = configClass.getOutFolder();
|
||||
|
||||
String otherTxnRef;
|
||||
String sqlStatement;
|
||||
String errorMessage;
|
||||
String txnCode;
|
||||
String hold;
|
||||
String bankWallet;
|
||||
String customerName;
|
||||
String customerBranch;
|
||||
String drAccount;
|
||||
String crAccount;
|
||||
String txnCurrency;
|
||||
Float txnAmount;
|
||||
String txnCharge;
|
||||
String txnNarration;
|
||||
String api;
|
||||
String requestType;
|
||||
String txnRef;
|
||||
String ftRef;
|
||||
String errorMsg;
|
||||
String statusMsg;
|
||||
String txnStatus = "";
|
||||
String account;
|
||||
Float sumBalance = 0.0F;
|
||||
Float newBalance = 0.0F;
|
||||
Float acBalance = 0.0F;
|
||||
Float fullAmt;
|
||||
|
||||
public String intReversal(String request) throws IOException {
|
||||
|
||||
JsonElement jsonElementAuth = JsonParser.parseString(request);
|
||||
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
|
||||
transactionDataServiceImpl = BeanUtil.getBean(TransactionDataServiceImpl.class);
|
||||
t24DataServiceImpl = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
t24DataServiceImplDr = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
t24DataServiceImplCr = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
try {
|
||||
|
||||
txnRef = jsonObjectAuth.get("ourTxnRef").getAsString();
|
||||
otherTxnRef = jsonObjectAuth.get("otherTxnRef").getAsString();
|
||||
|
||||
} catch (NullPointerException e) {
|
||||
errorMessage = e.getLocalizedMessage();
|
||||
}
|
||||
|
||||
if (txnRef.isEmpty()){
|
||||
errorMsg = "Payment Reference Empty";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
String transactionDataQuery = "SELECT * FROM " + transactionDataTable + " WHERE txnRef='" + otherTxnRef + "'";
|
||||
transactionDataEntity = entityManager.createNativeQuery(transactionDataQuery, TransactionDataEntity.class).getResultList();
|
||||
boolean isTxnEmpty = isEmpty(transactionDataEntity);
|
||||
if (isTxnEmpty){
|
||||
errorMsg = "Payment Reference Invalid - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
txnStatus = transactionDataEntity.get(0).getTxnStatus();
|
||||
if(txnStatus.equals("rev")){
|
||||
errorMsg = "Transaction Already Reversed - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
txnAmount = transactionDataEntity.get(0).getTxnAmount();
|
||||
drAccount = transactionDataEntity.get(0).getDrAccount() ;
|
||||
crAccount = transactionDataEntity.get(0).getCrAccount();
|
||||
|
||||
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable + " WHERE accountId='" + crAccount + "'";
|
||||
t24DataEntityCr = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isCreEmpty = isEmpty(t24DataEntityCr);
|
||||
if (isCreEmpty){
|
||||
errorMsg = "Credit Account Number - " + crAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable + " WHERE accountId='" + drAccount + "'";
|
||||
t24DataEntityDr = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isDebEmpty = isEmpty(t24DataEntityDr);
|
||||
if (isDebEmpty){
|
||||
errorMsg = "Debit Account Number - " + drAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
Float crBalance = t24DataEntityCr.get(0).getAccountBalance();
|
||||
Float drBalance = t24DataEntityDr.get(0).getAccountBalance();
|
||||
|
||||
Float newCrBalance = crBalance - txnAmount ;
|
||||
Float newDrBalance = drBalance + txnAmount;
|
||||
|
||||
transactionDataEntitySave.setTxnRef(otherTxnRef);
|
||||
transactionDataEntitySave.setApi(transactionDataEntity.get(0).getApi());
|
||||
transactionDataEntitySave.setHold(transactionDataEntity.get(0).getHold());
|
||||
transactionDataEntitySave.setRequestType(transactionDataEntity.get(0).getRequestType());
|
||||
transactionDataEntitySave.setFtId(transactionDataEntity.get(0).getFtId());
|
||||
transactionDataEntitySave.setTxnCode(transactionDataEntity.get(0).getTxnCode());
|
||||
transactionDataEntitySave.setBankWallet(transactionDataEntity.get(0).getBankWallet());
|
||||
transactionDataEntitySave.setCustomerName(transactionDataEntity.get(0).getCustomerName());
|
||||
transactionDataEntitySave.setCustomerBranch(transactionDataEntity.get(0).getCustomerBranch());
|
||||
transactionDataEntitySave.setDrAccount(drAccount);
|
||||
transactionDataEntitySave.setCrAccount(crAccount);
|
||||
transactionDataEntitySave.setTxnAmount(txnAmount);
|
||||
transactionDataEntitySave.setElevyCharge(transactionDataEntity.get(0).getElevyCharge());
|
||||
transactionDataEntitySave.setTxnCharge(transactionDataEntity.get(0).getTxnCharge());
|
||||
transactionDataEntitySave.setTxnCurrency(transactionDataEntity.get(0).getTxnCurrency());
|
||||
transactionDataEntitySave.setTxnNarration(transactionDataEntity.get(0).getTxnNarration());
|
||||
transactionDataEntitySave.setTxnStatus("rev");
|
||||
transactionDataEntitySave.setProcessFlag("Y");
|
||||
transactionDataEntitySave.setTransactionType(transactionDataEntity.get(0).getTransactionType());
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySaveDr.setAccountId(drAccount);
|
||||
t24DataEntitySaveDr.setAccountBalance(newDrBalance);
|
||||
t24DataEntitySaveDr.setCategory(t24DataEntityDr.get(0).getCategory());
|
||||
t24DataEntitySaveDr.setCustomerNo(t24DataEntityDr.get(0).getCustomerNo());
|
||||
t24DataEntitySaveDr.setCustomerName(t24DataEntityDr.get(0).getCustomerName());
|
||||
t24DataEntitySaveDr.setCustomerType(t24DataEntityDr.get(0).getCustomerType());
|
||||
t24DataEntitySaveDr.setCustomerId(t24DataEntityDr.get(0).getCustomerId());
|
||||
t24DataEntitySaveDr.setPhoneNumber(t24DataEntityDr.get(0).getPhoneNumber());
|
||||
t24DataEntitySaveDr.setBranch(t24DataEntityDr.get(0).getBranch());
|
||||
t24DataEntitySaveDr.setBranchName(t24DataEntityDr.get(0).getBranchName());
|
||||
t24DataEntitySaveDr.setDob(t24DataEntityDr.get(0).getDob());
|
||||
t24DataEntitySaveDr.setEmailAddress(t24DataEntityDr.get(0).getEmailAddress());
|
||||
t24DataEntitySaveDr.setGender(t24DataEntityDr.get(0).getGender());
|
||||
t24DataEntitySaveDr.setAcStatus(t24DataEntityDr.get(0).getAcStatus());
|
||||
t24DataEntitySaveDr.setMaxDebitBalance(t24DataEntityDr.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySaveDr.setMaxCreditBalance(t24DataEntityDr.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySaveDr.setDebitAllowed(t24DataEntityDr.get(0).getDebitAllowed());
|
||||
t24DataEntitySaveDr.setCreditAllowed(t24DataEntityDr.get(0).getCreditAllowed());
|
||||
t24DataEntitySaveDr.setUssdSubscribed(t24DataEntityDr.get(0).getUssdSubscribed());
|
||||
t24DataServiceImplDr.save(t24DataEntitySaveDr);
|
||||
|
||||
t24DataEntitySaveCr.setAccountId(crAccount);
|
||||
t24DataEntitySaveCr.setAccountBalance(newCrBalance);
|
||||
t24DataEntitySaveCr.setCategory(t24DataEntityCr.get(0).getCategory());
|
||||
t24DataEntitySaveCr.setCustomerNo(t24DataEntityCr.get(0).getCustomerNo());
|
||||
t24DataEntitySaveCr.setCustomerName(t24DataEntityCr.get(0).getCustomerName());
|
||||
t24DataEntitySaveCr.setCustomerType(t24DataEntityCr.get(0).getCustomerType());
|
||||
t24DataEntitySaveCr.setCustomerId(t24DataEntityCr.get(0).getCustomerId());
|
||||
t24DataEntitySaveCr.setPhoneNumber(t24DataEntityCr.get(0).getPhoneNumber());
|
||||
t24DataEntitySaveCr.setBranch(t24DataEntityCr.get(0).getBranch());
|
||||
t24DataEntitySaveCr.setBranchName(t24DataEntityCr.get(0).getBranchName());
|
||||
t24DataEntitySaveCr.setDob(t24DataEntityCr.get(0).getDob());
|
||||
t24DataEntitySaveCr.setEmailAddress(t24DataEntityCr.get(0).getEmailAddress());
|
||||
t24DataEntitySaveCr.setGender(t24DataEntityCr.get(0).getGender());
|
||||
t24DataEntitySaveCr.setAcStatus(t24DataEntityCr.get(0).getAcStatus());
|
||||
t24DataEntitySaveCr.setMaxDebitBalance(t24DataEntityCr.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySaveCr.setMaxCreditBalance(t24DataEntityCr.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySaveCr.setDebitAllowed(t24DataEntityCr.get(0).getDebitAllowed());
|
||||
t24DataEntitySaveCr.setCreditAllowed(t24DataEntityCr.get(0).getCreditAllowed());
|
||||
t24DataEntitySaveCr.setUssdSubscribed(t24DataEntityCr.get(0).getUssdSubscribed());
|
||||
t24DataServiceImplCr.save(t24DataEntitySaveCr);
|
||||
|
||||
errorMsg = "";
|
||||
statusMsg = "00";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
// public void txnWriter(String outRequest) throws IOException {
|
||||
// FileWriter myWriter = new FileWriter(outFolder + "/"+ txnRef + ".xml");
|
||||
// myWriter.write(outRequest);
|
||||
// myWriter.close();
|
||||
// }
|
||||
|
||||
public String outValue(String drAccount, String crAccount, String txnRef, String error, String status){
|
||||
//
|
||||
return "{\"txnCode\" :\"" + "intTrf" + "\",\"" +
|
||||
"drAccount\" :\"" + drAccount + "\",\"" +
|
||||
"crAccount\" :\"" + crAccount + "\",\"" +
|
||||
"transactionRef\" :\"" + "" + "\",\"" +
|
||||
"errorMsg\" :\"" + error + "\",\"" +
|
||||
"status\" :\"" + status + "\"" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,282 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.saslpay.config.AppPropertiesConfig;
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import com.saslpay.impl.TransactionDataServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.aspectj.util.LangUtil.isEmpty;
|
||||
|
||||
//@Component
|
||||
public class IntTransferCapture {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDataServiceImpl transactionDataServiceImpl;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImplCr;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImplDr;
|
||||
|
||||
TransactionDataEntity transactionDataEntitySave = new TransactionDataEntity();
|
||||
T24DataEntity t24DataEntitySaveCr = new T24DataEntity();
|
||||
T24DataEntity t24DataEntitySaveDr = new T24DataEntity();
|
||||
List<TransactionDataEntity> transactionDataEntity;
|
||||
List<T24DataEntity> t24DataEntityCr;
|
||||
List<T24DataEntity> t24DataEntityDr;
|
||||
|
||||
String drAccount;
|
||||
String crAccount;
|
||||
String txnCurrency;
|
||||
String txnAmount;
|
||||
String txnNarration;
|
||||
String errorMessage;
|
||||
String errorMsg;
|
||||
String statusMsg;
|
||||
String txnRef;
|
||||
String elevyCharge;
|
||||
String sqlStatement;
|
||||
Float sumBalance = 0.00F;
|
||||
Float newBalanceDr = 0.0F;
|
||||
Float newBalanceCr = 0.0F;
|
||||
Float minBalance = 0.0F;
|
||||
Float maxBalance = 0.0F;
|
||||
Float acBalanceDr = 0.0F;
|
||||
Float acBalanceCr = 0.0F;
|
||||
|
||||
// @Autowired
|
||||
AppPropertiesConfig appPropertiesConfig = BeanUtil.getBean(AppPropertiesConfig.class);
|
||||
String t24DataTable = appPropertiesConfig.getT24DataTable();
|
||||
String transactionDataTable = appPropertiesConfig.getTransactionDataTable();
|
||||
String outFolder = appPropertiesConfig.getOutFolder();
|
||||
|
||||
public String intTransfer(String request) throws IOException {
|
||||
|
||||
JsonElement jsonElementAuth = JsonParser.parseString(request);
|
||||
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
|
||||
transactionDataServiceImpl = BeanUtil.getBean(TransactionDataServiceImpl.class);
|
||||
t24DataServiceImplDr = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
t24DataServiceImplCr = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
try {
|
||||
txnRef = jsonObjectAuth.get("txnRef").getAsString();
|
||||
drAccount = jsonObjectAuth.get("drAccount").getAsString();
|
||||
crAccount = jsonObjectAuth.get("crAccount").getAsString();
|
||||
txnCurrency = jsonObjectAuth.get("currency").getAsString();
|
||||
txnAmount = jsonObjectAuth.get("txnAmount").getAsString();
|
||||
txnNarration = jsonObjectAuth.get("txnNarration").getAsString();
|
||||
elevyCharge = jsonObjectAuth.get("elevyCharge").getAsString();
|
||||
}catch (NullPointerException e){
|
||||
errorMessage = e.getLocalizedMessage();
|
||||
}
|
||||
|
||||
sumBalance = Float.parseFloat(txnAmount) + Float.parseFloat(elevyCharge);
|
||||
|
||||
if (txnRef.isEmpty()){
|
||||
errorMsg = "No Transaction Reference";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMessage,statusMsg);
|
||||
}
|
||||
|
||||
String transactionDataQuery = "SELECT * FROM " + transactionDataTable + " WHERE txnRef='" + txnRef + "'";
|
||||
transactionDataEntity = entityManager.createNativeQuery(transactionDataQuery, TransactionDataEntity.class).getResultList();
|
||||
boolean isTxnEmpty = isEmpty(transactionDataEntity);
|
||||
if (!isTxnEmpty){
|
||||
errorMsg = "Duplicate Transaction - " + txnRef;
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if (drAccount.equals(crAccount)) {
|
||||
errorMsg = "Cannot Debit and Credit Same Account Number";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable + " WHERE accountId='" + drAccount + "'";
|
||||
t24DataEntityDr = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isDebEmpty = isEmpty(t24DataEntityDr);
|
||||
if (isDebEmpty){
|
||||
errorMsg = "Debit Account Number - " + drAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
String debitAllowed = t24DataEntityDr.get(0).getDebitAllowed();
|
||||
if (debitAllowed.equals("N")) {
|
||||
errorMsg = drAccount + " Cannot Send Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
String inactiveMarker = t24DataEntityDr.get(0).getAcStatus();
|
||||
if (inactiveMarker.equals("Y")) {
|
||||
errorMsg = "Account Number - " + drAccount + " Inactive";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
minBalance = t24DataEntityDr.get(0).getMaxDebitBalance();
|
||||
maxBalance = t24DataEntityDr.get(0).getMaxCreditBalance();
|
||||
acBalanceDr = t24DataEntityDr.get(0).getAccountBalance();
|
||||
|
||||
if (sumBalance > acBalanceDr){
|
||||
errorMsg = "Account Number - " + drAccount + " has Insufficient Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
Float balanceDifference = acBalanceDr - sumBalance;
|
||||
if(minBalance > balanceDifference){
|
||||
errorMsg = "Debit Exceeds Minimum Balance";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
if (sumBalance > maxBalance){
|
||||
errorMsg = "Transaction Amount Exceeds Maximum Transaction Limit";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
newBalanceDr = balanceDifference;
|
||||
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable + " WHERE accountId='" + crAccount + "'";
|
||||
t24DataEntityCr = entityManager.createNativeQuery(sqlStatement,T24DataEntity.class).getResultList();
|
||||
boolean isCreEmpty = isEmpty(t24DataEntityCr);
|
||||
if (isCreEmpty){
|
||||
errorMsg = "Credit Account Number - " + crAccount + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
String creditAllowed = t24DataEntityCr.get(0).getCreditAllowed();
|
||||
if (creditAllowed.equals("N")) {
|
||||
errorMsg = crAccount + " - Account Product Not Allowed to Recieve Funds";
|
||||
statusMsg = "99";
|
||||
return outValue(drAccount,crAccount,"",errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
acBalanceCr = t24DataEntityCr.get(0).getAccountBalance();
|
||||
newBalanceCr = sumBalance + acBalanceCr;
|
||||
|
||||
String ftRef = geFundsTransferRef();
|
||||
|
||||
transactionDataEntitySave.setTxnRef(txnRef);
|
||||
transactionDataEntitySave.setApi("INTERNAL");
|
||||
transactionDataEntitySave.setHold("I");
|
||||
transactionDataEntitySave.setRequestType("A2A");
|
||||
transactionDataEntitySave.setFtId(ftRef);
|
||||
transactionDataEntitySave.setTxnCode("intTrf");
|
||||
transactionDataEntitySave.setBankWallet("BANK");
|
||||
transactionDataEntitySave.setCustomerName("");
|
||||
transactionDataEntitySave.setCustomerBranch("");
|
||||
transactionDataEntitySave.setDrAccount(drAccount);
|
||||
transactionDataEntitySave.setCrAccount(crAccount);
|
||||
transactionDataEntitySave.setTxnAmount(Float.parseFloat(txnAmount));
|
||||
transactionDataEntitySave.setElevyCharge(Float.parseFloat(elevyCharge));
|
||||
transactionDataEntitySave.setTxnCharge(Float.parseFloat("0"));
|
||||
transactionDataEntitySave.setTxnCurrency(txnCurrency);
|
||||
transactionDataEntitySave.setTxnNarration(txnNarration);
|
||||
transactionDataEntitySave.setTxnStatus("auth");
|
||||
transactionDataEntitySave.setTransactionType("intTransfer");
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySaveDr.setAccountId(drAccount);
|
||||
t24DataEntitySaveDr.setAccountBalance(newBalanceDr);
|
||||
t24DataEntitySaveDr.setCategory(t24DataEntityDr.get(0).getCategory());
|
||||
t24DataEntitySaveDr.setCustomerNo(t24DataEntityDr.get(0).getCustomerNo());
|
||||
t24DataEntitySaveDr.setCustomerName(t24DataEntityDr.get(0).getCustomerName());
|
||||
t24DataEntitySaveDr.setCustomerType(t24DataEntityDr.get(0).getCustomerType());
|
||||
t24DataEntitySaveDr.setCustomerId(t24DataEntityDr.get(0).getCustomerId());
|
||||
t24DataEntitySaveDr.setPhoneNumber(t24DataEntityDr.get(0).getPhoneNumber());
|
||||
t24DataEntitySaveDr.setBranch(t24DataEntityDr.get(0).getBranch());
|
||||
t24DataEntitySaveDr.setBranchName(t24DataEntityDr.get(0).getBranchName());
|
||||
t24DataEntitySaveDr.setDob(t24DataEntityDr.get(0).getDob());
|
||||
t24DataEntitySaveDr.setEmailAddress(t24DataEntityDr.get(0).getEmailAddress());
|
||||
t24DataEntitySaveDr.setGender(t24DataEntityDr.get(0).getGender());
|
||||
t24DataEntitySaveDr.setAcStatus(t24DataEntityDr.get(0).getAcStatus());
|
||||
t24DataEntitySaveDr.setMaxDebitBalance(t24DataEntityDr.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySaveDr.setMaxCreditBalance(t24DataEntityDr.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySaveDr.setDebitAllowed(t24DataEntityDr.get(0).getDebitAllowed());
|
||||
t24DataEntitySaveDr.setCreditAllowed(t24DataEntityDr.get(0).getCreditAllowed());
|
||||
t24DataEntitySaveDr.setUssdSubscribed(t24DataEntityDr.get(0).getUssdSubscribed());
|
||||
t24DataServiceImplDr.save(t24DataEntitySaveDr);
|
||||
|
||||
t24DataEntitySaveCr.setAccountId(crAccount);
|
||||
t24DataEntitySaveCr.setAccountBalance(newBalanceCr);
|
||||
t24DataEntitySaveCr.setCategory(t24DataEntityCr.get(0).getCategory());
|
||||
t24DataEntitySaveCr.setCustomerNo(t24DataEntityCr.get(0).getCustomerNo());
|
||||
t24DataEntitySaveCr.setCustomerName(t24DataEntityCr.get(0).getCustomerName());
|
||||
t24DataEntitySaveCr.setCustomerType(t24DataEntityCr.get(0).getCustomerType());
|
||||
t24DataEntitySaveCr.setCustomerId(t24DataEntityCr.get(0).getCustomerId());
|
||||
t24DataEntitySaveCr.setPhoneNumber(t24DataEntityCr.get(0).getPhoneNumber());
|
||||
t24DataEntitySaveCr.setBranch(t24DataEntityCr.get(0).getBranch());
|
||||
t24DataEntitySaveCr.setBranchName(t24DataEntityCr.get(0).getBranchName());
|
||||
t24DataEntitySaveCr.setDob(t24DataEntityCr.get(0).getDob());
|
||||
t24DataEntitySaveCr.setEmailAddress(t24DataEntityCr.get(0).getEmailAddress());
|
||||
t24DataEntitySaveCr.setGender(t24DataEntityCr.get(0).getGender());
|
||||
t24DataEntitySaveCr.setAcStatus(t24DataEntityCr.get(0).getAcStatus());
|
||||
t24DataEntitySaveCr.setMaxDebitBalance(t24DataEntityCr.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySaveCr.setMaxCreditBalance(t24DataEntityCr.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySaveCr.setDebitAllowed(t24DataEntityCr.get(0).getDebitAllowed());
|
||||
t24DataEntitySaveCr.setCreditAllowed(t24DataEntityCr.get(0).getCreditAllowed());
|
||||
t24DataEntitySaveCr.setUssdSubscribed(t24DataEntityCr.get(0).getUssdSubscribed());
|
||||
t24DataServiceImplCr.save(t24DataEntitySaveCr);
|
||||
|
||||
// FileWriter myWriter = new FileWriter(outFolder + "/"+ txnRef + ".xml");
|
||||
// myWriter.write(request);
|
||||
// myWriter.close();
|
||||
|
||||
errorMsg = "";
|
||||
statusMsg = "00";
|
||||
return outValue(drAccount,crAccount,ftRef,errorMsg,statusMsg);
|
||||
}
|
||||
//
|
||||
public String outValue(String drAccount, String crAccount, String ftRef, String error, String status){
|
||||
//
|
||||
return "{\"txnCode\" :\"" + "intTrf" + "\",\"" +
|
||||
"drAccount\" :\"" + drAccount + "\",\"" +
|
||||
"crAccount\" :\"" + crAccount + "\",\"" +
|
||||
"transactionRef\" :\"" + ftRef + "\",\"" +
|
||||
"errorMsg\" :\"" + error + "\",\"" +
|
||||
"status\" :\"" + status + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
||||
public String geFundsTransferRef() {
|
||||
int leftLimit = 48; // numeral '0'
|
||||
int rightLimit = 122; // letter 'z'
|
||||
int targetStringLength = 6;
|
||||
Random random = new Random();
|
||||
int day = LocalDate.now().getDayOfYear();
|
||||
String year = String.valueOf(LocalDate.now()).substring(2, 4);
|
||||
String paddedString = StringUtils.leftPad(String.valueOf(day), 3, "0");
|
||||
String generatedString = random.ints(leftLimit, rightLimit + 1)
|
||||
.filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
|
||||
.limit(targetStringLength)
|
||||
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
|
||||
.toString();
|
||||
return "FT" + year + paddedString + generatedString.toUpperCase();
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class JwtRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 5926468583005150707L;
|
||||
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
//need default constructor for JSON Parsing
|
||||
public JwtRequest()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public JwtRequest(String username, String password) {
|
||||
this.setUsername(username);
|
||||
this.setPassword(password);
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
}
|
||||
+17
@@ -0,0 +1,17 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class JwtResponse implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -8091879091924046844L;
|
||||
private final String jwttoken;
|
||||
|
||||
public JwtResponse(String jwttoken) {
|
||||
this.jwttoken = jwttoken;
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
return this.jwttoken;
|
||||
}
|
||||
}
|
||||
+162
@@ -0,0 +1,162 @@
|
||||
package com.saslpay.datacapture;
|
||||
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.saslpay.config.AppPropertiesConfig;
|
||||
import com.saslpay.config.BeanUtil;
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import com.saslpay.impl.T24DataServiceImpl;
|
||||
import com.saslpay.impl.TransactionDataServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.aspectj.util.LangUtil.isEmpty;
|
||||
|
||||
public class LevyPay {
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Autowired
|
||||
TransactionDataServiceImpl transactionDataServiceImpl;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImplCr;
|
||||
|
||||
@Autowired
|
||||
T24DataServiceImpl t24DataServiceImplDr;
|
||||
|
||||
TransactionDataEntity transactionDataEntitySave = new TransactionDataEntity();
|
||||
T24DataEntity t24DataEntitySave = new T24DataEntity();
|
||||
List<TransactionDataEntity> transactionDataEntity;
|
||||
List<T24DataEntity> t24DataEntity;
|
||||
|
||||
String sqlStatement;
|
||||
String txnCode;
|
||||
String account;
|
||||
String chgAmt;
|
||||
String errorMsg;
|
||||
String statusMsg;
|
||||
Float newBalance = 0.00F;
|
||||
|
||||
AppPropertiesConfig appPropertiesConfig = BeanUtil.getBean(AppPropertiesConfig.class);
|
||||
String t24DataTable = appPropertiesConfig.getT24DataTable();
|
||||
|
||||
public String levyPay(String request){
|
||||
|
||||
JsonElement jsonElementAuth = JsonParser.parseString(request);
|
||||
JsonObject jsonObjectAuth = jsonElementAuth.getAsJsonObject();
|
||||
transactionDataServiceImpl = BeanUtil.getBean(TransactionDataServiceImpl.class);
|
||||
t24DataServiceImplDr = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
t24DataServiceImplCr = BeanUtil.getBean(T24DataServiceImpl.class);
|
||||
entityManager = BeanUtil.getBean(EntityManager.class);
|
||||
|
||||
try {
|
||||
|
||||
txnCode = jsonObjectAuth.get("txnCode").getAsString();
|
||||
account = jsonObjectAuth.get("account").getAsString();
|
||||
chgAmt = jsonObjectAuth.get("chgAmt").getAsString();
|
||||
|
||||
} catch (NullPointerException e){
|
||||
e.getLocalizedMessage();
|
||||
}
|
||||
|
||||
sqlStatement = "SELECT * FROM " + t24DataTable +" WHERE accountId='" + account + "'";
|
||||
t24DataEntity = entityManager.createNativeQuery(sqlStatement, T24DataEntity.class).getResultList();
|
||||
boolean isCreEmpty = isEmpty(t24DataEntity);
|
||||
if (isCreEmpty){
|
||||
errorMsg = "Account Number - " + account + " Does Not Exist";
|
||||
statusMsg = "99";
|
||||
return null;
|
||||
//return outValue(api, txnCode, requestType, drAccount,crAccount,txnRef,errorMsg,statusMsg);
|
||||
}
|
||||
|
||||
Float acBalance = t24DataEntity.get(0).getAccountBalance();
|
||||
switch (txnCode){
|
||||
case "debit":
|
||||
|
||||
newBalance = acBalance - Float.parseFloat(chgAmt);
|
||||
|
||||
case "credit":
|
||||
|
||||
newBalance = acBalance + Float.parseFloat(chgAmt);
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
String ftRef = geFundsTransferRef();
|
||||
transactionDataEntitySave.setTxnRef(ftRef);
|
||||
transactionDataEntitySave.setApi("LEVY");
|
||||
transactionDataEntitySave.setHold("");
|
||||
transactionDataEntitySave.setRequestType("LEVY");
|
||||
transactionDataEntitySave.setFtId(ftRef);
|
||||
transactionDataEntitySave.setTxnCode(txnCode);
|
||||
transactionDataEntitySave.setBankWallet("BANK");
|
||||
transactionDataEntitySave.setCustomerName("");
|
||||
transactionDataEntitySave.setCustomerBranch("");
|
||||
transactionDataEntitySave.setDrAccount(account);
|
||||
transactionDataEntitySave.setCrAccount(account);
|
||||
transactionDataEntitySave.setTxnAmount(Float.parseFloat("0.00"));
|
||||
transactionDataEntitySave.setElevyCharge(Float.parseFloat(chgAmt));
|
||||
transactionDataEntitySave.setTxnCharge(Float.parseFloat("0"));
|
||||
transactionDataEntitySave.setTxnCurrency("GHS");
|
||||
transactionDataEntitySave.setTxnNarration("Elvey Charge");
|
||||
transactionDataEntitySave.setTransactionType("levyCharge");
|
||||
transactionDataEntitySave.setTxnStatus("auth");
|
||||
transactionDataServiceImpl.save(transactionDataEntitySave);
|
||||
|
||||
t24DataEntitySave.setAccountId(account);
|
||||
t24DataEntitySave.setAccountBalance(newBalance);
|
||||
t24DataEntitySave.setCategory(t24DataEntity.get(0).getCategory());
|
||||
t24DataEntitySave.setCustomerNo(t24DataEntity.get(0).getCustomerNo());
|
||||
t24DataEntitySave.setCustomerName(t24DataEntity.get(0).getCustomerName());
|
||||
t24DataEntitySave.setCustomerType(t24DataEntity.get(0).getCustomerType());
|
||||
t24DataEntitySave.setCustomerId(t24DataEntity.get(0).getCustomerId());
|
||||
t24DataEntitySave.setPhoneNumber(t24DataEntity.get(0).getPhoneNumber());
|
||||
t24DataEntitySave.setBranch(t24DataEntity.get(0).getBranch());
|
||||
t24DataEntitySave.setBranchName(t24DataEntity.get(0).getBranchName());
|
||||
t24DataEntitySave.setDob(t24DataEntity.get(0).getDob());
|
||||
t24DataEntitySave.setEmailAddress(t24DataEntity.get(0).getEmailAddress());
|
||||
t24DataEntitySave.setGender(t24DataEntity.get(0).getGender());
|
||||
t24DataEntitySave.setAcStatus(t24DataEntity.get(0).getAcStatus());
|
||||
t24DataEntitySave.setMaxDebitBalance(t24DataEntity.get(0).getMaxDebitBalance());
|
||||
t24DataEntitySave.setMaxCreditBalance(t24DataEntity.get(0).getMaxCreditBalance());
|
||||
t24DataEntitySave.setDebitAllowed(t24DataEntity.get(0).getDebitAllowed());
|
||||
t24DataEntitySave.setCreditAllowed(t24DataEntity.get(0).getCreditAllowed());
|
||||
t24DataEntitySave.setUssdSubscribed(t24DataEntity.get(0).getUssdSubscribed());
|
||||
t24DataServiceImplDr.save(t24DataEntitySave);
|
||||
|
||||
return "{\"txnCode\" :\"" + txnCode + "\",\"" +
|
||||
"ourTxnRef\" :\"" + ftRef + "\",\"" +
|
||||
"account\" :\"" + account + "\",\"" +
|
||||
"chgAmt\" :\"" + chgAmt + "\",\"" +
|
||||
"errorMsg\" :\"" + "" + "\",\"" +
|
||||
"status\" :\"" + "00" + "\"" +
|
||||
"}";
|
||||
}
|
||||
|
||||
public String geFundsTransferRef() {
|
||||
int leftLimit = 48; // numeral '0'
|
||||
int rightLimit = 122; // letter 'z'
|
||||
int targetStringLength = 6;
|
||||
Random random = new Random();
|
||||
int day = LocalDate.now().getDayOfYear();
|
||||
String year = String.valueOf(LocalDate.now()).substring(2, 4);
|
||||
String paddedString = StringUtils.leftPad(String.valueOf(day), 3, "0");
|
||||
String generatedString = random.ints(leftLimit, rightLimit + 1)
|
||||
.filter(i -> (i <= 57 || i >= 65) && (i <= 90 || i >= 97))
|
||||
.limit(targetStringLength)
|
||||
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
|
||||
.toString();
|
||||
return "FT" + year + paddedString + generatedString.toUpperCase();
|
||||
}
|
||||
}
|
||||
+290
@@ -0,0 +1,290 @@
|
||||
package com.saslpay.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "t24Data")
|
||||
public class T24DataEntity {
|
||||
private String accountId;
|
||||
private String category;
|
||||
private String customerNo;
|
||||
private String customerName;
|
||||
private String customerType;
|
||||
private String customerId;
|
||||
private String phoneNumber;
|
||||
private String branch;
|
||||
private String branchName;
|
||||
private String dob;
|
||||
private String emailAddress;
|
||||
private String gender;
|
||||
private String acStatus;
|
||||
private Float accountBalance;
|
||||
private Float maxCreditBalance;
|
||||
private Float maxDebitBalance;
|
||||
private String debitAllowed;
|
||||
private String creditAllowed;
|
||||
private String ussdSubscribed;
|
||||
private Timestamp timeStamp;
|
||||
|
||||
@Id
|
||||
@Column(name = "accountId", nullable = false, length = 13)
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "category", nullable = true, length = 5)
|
||||
public String getCategory() {
|
||||
return category;
|
||||
}
|
||||
|
||||
public void setCategory(String category) {
|
||||
this.category = category;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "customerNo", nullable = false, length = 35)
|
||||
public String getCustomerNo() {
|
||||
return customerNo;
|
||||
}
|
||||
|
||||
public void setCustomerNo(String customerNo) {
|
||||
this.customerNo = customerNo;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "customerName", nullable = true, length = 35)
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "customerType", nullable = true, length = 2)
|
||||
public String getCustomerType() {
|
||||
return customerType;
|
||||
}
|
||||
|
||||
public void setCustomerType(String customerType) {
|
||||
this.customerType = customerType;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "customerId", nullable = true, length = 35)
|
||||
public String getCustomerId() {
|
||||
return customerId;
|
||||
}
|
||||
|
||||
public void setCustomerId(String customerId) {
|
||||
this.customerId = customerId;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "phoneNumber", nullable = true, length = 16)
|
||||
public String getPhoneNumber() {
|
||||
return phoneNumber;
|
||||
}
|
||||
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "branch", nullable = true, length = 35)
|
||||
public String getBranch() {
|
||||
return branch;
|
||||
}
|
||||
|
||||
public void setBranch(String branch) {
|
||||
this.branch = branch;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "branchName", nullable = true, length = 35)
|
||||
public String getBranchName() {
|
||||
return branchName;
|
||||
}
|
||||
|
||||
public void setBranchName(String branchName) {
|
||||
this.branchName = branchName;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "dob", nullable = true)
|
||||
public String getDob() {
|
||||
return dob;
|
||||
}
|
||||
|
||||
public void setDob(String dob) {
|
||||
this.dob = dob;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "emailAddress", nullable = true, length = 35)
|
||||
public String getEmailAddress() {
|
||||
return emailAddress;
|
||||
}
|
||||
|
||||
public void setEmailAddress(String emailAddress) {
|
||||
this.emailAddress = emailAddress;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "gender", nullable = true, length = 10)
|
||||
public String getGender() {
|
||||
return gender;
|
||||
}
|
||||
|
||||
public void setGender(String gender) {
|
||||
this.gender = gender;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "acStatus", nullable = true, length = 11)
|
||||
public String getAcStatus() {
|
||||
return acStatus;
|
||||
}
|
||||
|
||||
public void setAcStatus(String acStatus) {
|
||||
this.acStatus = acStatus;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "accountBalance", nullable = true, precision = 2)
|
||||
public Float getAccountBalance() {
|
||||
return accountBalance;
|
||||
}
|
||||
|
||||
public void setAccountBalance(Float accountBalance) {
|
||||
this.accountBalance = accountBalance;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "maxCreditBalance", nullable = true, precision = 2)
|
||||
public Float getMaxCreditBalance() {
|
||||
return maxCreditBalance;
|
||||
}
|
||||
|
||||
public void setMaxCreditBalance(Float maxCreditBalance) {
|
||||
this.maxCreditBalance = maxCreditBalance;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "maxDebitBalance", nullable = true, precision = 2)
|
||||
public Float getMaxDebitBalance() {
|
||||
return maxDebitBalance;
|
||||
}
|
||||
|
||||
public void setMaxDebitBalance(Float maxDebitBalance) {
|
||||
this.maxDebitBalance = maxDebitBalance;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "debitAllowed", nullable = true, length = 11)
|
||||
public String getDebitAllowed() {
|
||||
return debitAllowed;
|
||||
}
|
||||
|
||||
public void setDebitAllowed(String debitAllowed) {
|
||||
this.debitAllowed = debitAllowed;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "creditAllowed", nullable = true, length = 11)
|
||||
public String getCreditAllowed() {
|
||||
return creditAllowed;
|
||||
}
|
||||
|
||||
public void setCreditAllowed(String creditAllowed) {
|
||||
this.creditAllowed = creditAllowed;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "ussdSubscribed", nullable = true, length = 2)
|
||||
public String getUssdSubscribed() {
|
||||
return ussdSubscribed;
|
||||
}
|
||||
|
||||
public void setUssdSubscribed(String ussdSubscribed) {
|
||||
this.ussdSubscribed = ussdSubscribed;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "timeStamp", nullable = true)
|
||||
public Timestamp getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(Timestamp timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
T24DataEntity that = (T24DataEntity) o;
|
||||
|
||||
if (accountId != null ? !accountId.equals(that.accountId) : that.accountId != null) return false;
|
||||
if (category != null ? !category.equals(that.category) : that.category != null) return false;
|
||||
if (customerNo != null ? !customerNo.equals(that.customerNo) : that.customerNo != null) return false;
|
||||
if (customerName != null ? !customerName.equals(that.customerName) : that.customerName != null) return false;
|
||||
if (customerType != null ? !customerType.equals(that.customerType) : that.customerType != null) return false;
|
||||
if (customerId != null ? !customerId.equals(that.customerId) : that.customerId != null) return false;
|
||||
if (phoneNumber != null ? !phoneNumber.equals(that.phoneNumber) : that.phoneNumber != null) return false;
|
||||
if (branch != null ? !branch.equals(that.branch) : that.branch != null) return false;
|
||||
if (branchName != null ? !branchName.equals(that.branchName) : that.branchName != null) return false;
|
||||
if (dob != null ? !dob.equals(that.dob) : that.dob != null) return false;
|
||||
if (emailAddress != null ? !emailAddress.equals(that.emailAddress) : that.emailAddress != null) return false;
|
||||
if (gender != null ? !gender.equals(that.gender) : that.gender != null) return false;
|
||||
if (acStatus != null ? !acStatus.equals(that.acStatus) : that.acStatus != null) return false;
|
||||
if (accountBalance != null ? !accountBalance.equals(that.accountBalance) : that.accountBalance != null)
|
||||
return false;
|
||||
if (maxCreditBalance != null ? !maxCreditBalance.equals(that.maxCreditBalance) : that.maxCreditBalance != null)
|
||||
return false;
|
||||
if (maxDebitBalance != null ? !maxDebitBalance.equals(that.maxDebitBalance) : that.maxDebitBalance != null)
|
||||
return false;
|
||||
if (debitAllowed != null ? !debitAllowed.equals(that.debitAllowed) : that.debitAllowed != null) return false;
|
||||
if (creditAllowed != null ? !creditAllowed.equals(that.creditAllowed) : that.creditAllowed != null)
|
||||
return false;
|
||||
if (ussdSubscribed != null ? !ussdSubscribed.equals(that.ussdSubscribed) : that.ussdSubscribed != null)
|
||||
return false;
|
||||
if (timeStamp != null ? !timeStamp.equals(that.timeStamp) : that.timeStamp != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = accountId != null ? accountId.hashCode() : 0;
|
||||
result = 31 * result + (category != null ? category.hashCode() : 0);
|
||||
result = 31 * result + (customerNo != null ? customerNo.hashCode() : 0);
|
||||
result = 31 * result + (customerName != null ? customerName.hashCode() : 0);
|
||||
result = 31 * result + (customerType != null ? customerType.hashCode() : 0);
|
||||
result = 31 * result + (customerId != null ? customerId.hashCode() : 0);
|
||||
result = 31 * result + (phoneNumber != null ? phoneNumber.hashCode() : 0);
|
||||
result = 31 * result + (branch != null ? branch.hashCode() : 0);
|
||||
result = 31 * result + (branchName != null ? branchName.hashCode() : 0);
|
||||
result = 31 * result + (dob != null ? dob.hashCode() : 0);
|
||||
result = 31 * result + (emailAddress != null ? emailAddress.hashCode() : 0);
|
||||
result = 31 * result + (gender != null ? gender.hashCode() : 0);
|
||||
result = 31 * result + (acStatus != null ? acStatus.hashCode() : 0);
|
||||
result = 31 * result + (accountBalance != null ? accountBalance.hashCode() : 0);
|
||||
result = 31 * result + (maxCreditBalance != null ? maxCreditBalance.hashCode() : 0);
|
||||
result = 31 * result + (maxDebitBalance != null ? maxDebitBalance.hashCode() : 0);
|
||||
result = 31 * result + (debitAllowed != null ? debitAllowed.hashCode() : 0);
|
||||
result = 31 * result + (creditAllowed != null ? creditAllowed.hashCode() : 0);
|
||||
result = 31 * result + (ussdSubscribed != null ? ussdSubscribed.hashCode() : 0);
|
||||
result = 31 * result + (timeStamp != null ? timeStamp.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
package com.saslpay.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.sql.Timestamp;
|
||||
|
||||
@Entity
|
||||
@Table(name = "transactionData", schema = "saslinterfacebkptest", catalog = "")
|
||||
public class TransactionDataEntity {
|
||||
private String txnRef;
|
||||
private String ftId;
|
||||
private String api;
|
||||
private String txnCode;
|
||||
private String hold;
|
||||
private String requestType;
|
||||
private String bankWallet;
|
||||
private String customerName;
|
||||
private String customerBranch;
|
||||
private String drAccount;
|
||||
private String crAccount;
|
||||
private String txnCurrency;
|
||||
private Float txnAmount;
|
||||
private Float txnCharge;
|
||||
private String txnNarration;
|
||||
private Float elevyCharge;
|
||||
private String processFlag;
|
||||
private String txnStatus;
|
||||
private Timestamp timeStamp;
|
||||
private String transactionType;
|
||||
|
||||
@Id
|
||||
@Column(name = "txnRef", nullable = false, length = 35)
|
||||
public String getTxnRef() {
|
||||
return txnRef;
|
||||
}
|
||||
|
||||
public void setTxnRef(String txnRef) {
|
||||
this.txnRef = txnRef;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "ftId", nullable = false, length = 35)
|
||||
public String getFtId() {
|
||||
return ftId;
|
||||
}
|
||||
|
||||
public void setFtId(String ftId) {
|
||||
this.ftId = ftId;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "api", nullable = false, length = 35)
|
||||
public String getApi() {
|
||||
return api;
|
||||
}
|
||||
|
||||
public void setApi(String api) {
|
||||
this.api = api;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "txnCode", nullable = false, length = 35)
|
||||
public String getTxnCode() {
|
||||
return txnCode;
|
||||
}
|
||||
|
||||
public void setTxnCode(String txnCode) {
|
||||
this.txnCode = txnCode;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "hold", nullable = false, length = 1)
|
||||
public String getHold() {
|
||||
return hold;
|
||||
}
|
||||
|
||||
public void setHold(String hold) {
|
||||
this.hold = hold;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "requestType", nullable = false, length = 35)
|
||||
public String getRequestType() {
|
||||
return requestType;
|
||||
}
|
||||
|
||||
public void setRequestType(String requestType) {
|
||||
this.requestType = requestType;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "bankWallet", nullable = true, length = 35)
|
||||
public String getBankWallet() {
|
||||
return bankWallet;
|
||||
}
|
||||
|
||||
public void setBankWallet(String bankWallet) {
|
||||
this.bankWallet = bankWallet;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "customerName", nullable = true, length = 35)
|
||||
public String getCustomerName() {
|
||||
return customerName;
|
||||
}
|
||||
|
||||
public void setCustomerName(String customerName) {
|
||||
this.customerName = customerName;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "customerBranch", nullable = true, length = 35)
|
||||
public String getCustomerBranch() {
|
||||
return customerBranch;
|
||||
}
|
||||
|
||||
public void setCustomerBranch(String customerBranch) {
|
||||
this.customerBranch = customerBranch;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "drAccount", nullable = false, precision = 0, length = 35)
|
||||
public String getDrAccount() {
|
||||
return drAccount;
|
||||
}
|
||||
|
||||
public void setDrAccount(String drAccount) {
|
||||
this.drAccount = drAccount;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "crAccount", nullable = true, precision = 0, length = 35)
|
||||
public String getCrAccount() {
|
||||
return crAccount;
|
||||
}
|
||||
|
||||
public void setCrAccount(String crAccount) {
|
||||
this.crAccount = crAccount;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "txnCurrency", nullable = false, length = 3)
|
||||
public String getTxnCurrency() {
|
||||
return txnCurrency;
|
||||
}
|
||||
|
||||
public void setTxnCurrency(String txnCurrency) {
|
||||
this.txnCurrency = txnCurrency;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "txnAmount", nullable = false, precision = 0)
|
||||
public Float getTxnAmount() {
|
||||
return txnAmount;
|
||||
}
|
||||
|
||||
public void setTxnAmount(Float txnAmount) {
|
||||
this.txnAmount = txnAmount;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "txnCharge", nullable = false, precision = 0)
|
||||
public Float getTxnCharge() {
|
||||
return txnCharge;
|
||||
}
|
||||
|
||||
public void setTxnCharge(float txnCharge) {
|
||||
this.txnCharge = txnCharge;
|
||||
}
|
||||
|
||||
public void setTxnCharge(Float txnCharge) {
|
||||
this.txnCharge = txnCharge;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "txnNarration", nullable = true, length = 11)
|
||||
public String getTxnNarration() {
|
||||
return txnNarration;
|
||||
}
|
||||
|
||||
public void setTxnNarration(String txnNarration) {
|
||||
this.txnNarration = txnNarration;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "elevyCharge", nullable = false, precision = 0)
|
||||
public Float getElevyCharge() {
|
||||
return elevyCharge;
|
||||
}
|
||||
|
||||
public void setElevyCharge(float elevyCharge) {
|
||||
this.elevyCharge = elevyCharge;
|
||||
}
|
||||
|
||||
public void setElevyCharge(Float elevyCharge) {
|
||||
this.elevyCharge = elevyCharge;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "processFlag", nullable = true, length = 11)
|
||||
public String getProcessFlag() {
|
||||
return processFlag;
|
||||
}
|
||||
|
||||
public void setProcessFlag(String processFlag) {
|
||||
this.processFlag = processFlag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
TransactionDataEntity that = (TransactionDataEntity) o;
|
||||
|
||||
if (Double.compare(that.txnAmount, txnAmount) != 0) return false;
|
||||
if (Double.compare(that.txnCharge, txnCharge) != 0) return false;
|
||||
if (Double.compare(that.elevyCharge, elevyCharge) != 0) return false;
|
||||
if (drAccount != null ? !drAccount.equals(that.drAccount) : that.drAccount != null) return false;
|
||||
if (crAccount != null ? !crAccount.equals(that.crAccount) : that.crAccount != null) return false;
|
||||
if (txnRef != null ? !txnRef.equals(that.txnRef) : that.txnRef != null) return false;
|
||||
if (ftId != null ? !ftId.equals(that.ftId) : that.ftId != null) return false;
|
||||
if (api != null ? !api.equals(that.api) : that.api != null) return false;
|
||||
if (txnCode != null ? !txnCode.equals(that.txnCode) : that.txnCode != null) return false;
|
||||
if (hold != null ? !hold.equals(that.hold) : that.hold != null) return false;
|
||||
if (requestType != null ? !requestType.equals(that.requestType) : that.requestType != null) return false;
|
||||
if (bankWallet != null ? !bankWallet.equals(that.bankWallet) : that.bankWallet != null) return false;
|
||||
if (customerName != null ? !customerName.equals(that.customerName) : that.customerName != null) return false;
|
||||
if (customerBranch != null ? !customerBranch.equals(that.customerBranch) : that.customerBranch != null)
|
||||
return false;
|
||||
if (txnCurrency != null ? !txnCurrency.equals(that.txnCurrency) : that.txnCurrency != null) return false;
|
||||
if (txnNarration != null ? !txnNarration.equals(that.txnNarration) : that.txnNarration != null) return false;
|
||||
if (processFlag != null ? !processFlag.equals(that.processFlag) : that.processFlag != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "txnStatus", nullable = false, length = 4)
|
||||
public String getTxnStatus() {
|
||||
return txnStatus;
|
||||
}
|
||||
|
||||
public void setTxnStatus(String txnStatus) {
|
||||
this.txnStatus = txnStatus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = txnRef != null ? txnRef.hashCode() : 0;
|
||||
result = 31 * result + (ftId != null ? ftId.hashCode() : 0);
|
||||
result = 31 * result + (api != null ? api.hashCode() : 0);
|
||||
result = 31 * result + (txnCode != null ? txnCode.hashCode() : 0);
|
||||
result = 31 * result + (hold != null ? hold.hashCode() : 0);
|
||||
result = 31 * result + (requestType != null ? requestType.hashCode() : 0);
|
||||
result = 31 * result + (bankWallet != null ? bankWallet.hashCode() : 0);
|
||||
result = 31 * result + (customerName != null ? customerName.hashCode() : 0);
|
||||
result = 31 * result + (customerBranch != null ? customerBranch.hashCode() : 0);
|
||||
result = 31 * result + (drAccount != null ? drAccount.hashCode() : 0);
|
||||
result = 31 * result + (crAccount != null ? crAccount.hashCode() : 0);
|
||||
result = 31 * result + (txnCurrency != null ? txnCurrency.hashCode() : 0);
|
||||
temp = Double.doubleToLongBits(txnAmount);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(txnCharge);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 31 * result + (txnNarration != null ? txnNarration.hashCode() : 0);
|
||||
temp = Double.doubleToLongBits(elevyCharge);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 31 * result + (processFlag != null ? processFlag.hashCode() : 0);
|
||||
result = 31 * result + (txnStatus != null ? txnStatus.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "timeStamp")
|
||||
public Timestamp getTimeStamp() {
|
||||
return timeStamp;
|
||||
}
|
||||
|
||||
public void setTimeStamp(Timestamp timeStamp) {
|
||||
this.timeStamp = timeStamp;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "transactionType")
|
||||
public String getTransactionType() {
|
||||
return transactionType;
|
||||
}
|
||||
|
||||
public void setTransactionType(String transactionType) {
|
||||
this.transactionType = transactionType;
|
||||
}
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
package com.saslpay.entities;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Entity
|
||||
@Table(name = "user")
|
||||
public class UserEntity {
|
||||
private float userId;
|
||||
private String username;
|
||||
private String password;
|
||||
|
||||
@Id
|
||||
@Column(name = "userId", nullable = false, precision = 0)
|
||||
public float getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(float userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "username", nullable = false, length = 15)
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Basic
|
||||
@Column(name = "password", nullable = false, length = 200)
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
UserEntity that = (UserEntity) o;
|
||||
|
||||
if (Float.compare(that.userId, userId) != 0) return false;
|
||||
if (username != null ? !username.equals(that.username) : that.username != null) return false;
|
||||
if (password != null ? !password.equals(that.password) : that.password != null) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (userId != +0.0f ? Float.floatToIntBits(userId) : 0);
|
||||
result = 31 * result + (username != null ? username.hashCode() : 0);
|
||||
result = 31 * result + (password != null ? password.hashCode() : 0);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.saslpay.impl;
|
||||
|
||||
import com.saslpay.entities.UserEntity;
|
||||
import com.saslpay.repository.UserRepository;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.core.userdetails.User;
|
||||
import org.springframework.security.core.userdetails.UserDetails;
|
||||
import org.springframework.security.core.userdetails.UserDetailsService;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Service
|
||||
public class JwtUserDetailsService implements UserDetailsService {
|
||||
|
||||
@Autowired
|
||||
private UserRepository userDao;
|
||||
|
||||
@Autowired
|
||||
PasswordEncoder bcryptEncoder;
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
UserEntity user = userDao.findByUsername(username);
|
||||
if (user == null) {
|
||||
throw new UsernameNotFoundException("User not found with username: " + username);
|
||||
}
|
||||
return new User(user.getUsername(), user.getPassword(),
|
||||
new ArrayList<>());
|
||||
}
|
||||
|
||||
public UserEntity save(UserEntity user) {
|
||||
UserEntity newUser = new UserEntity();
|
||||
newUser.setUsername(user.getUsername());
|
||||
newUser.setPassword(bcryptEncoder.encode(user.getPassword()));
|
||||
return userDao.save(newUser);
|
||||
}
|
||||
|
||||
public String failed(UserEntity user) {
|
||||
return "{Invalid User}" ;
|
||||
}
|
||||
}
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.saslpay.impl;
|
||||
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import com.saslpay.repository.T24DataRepository;
|
||||
import com.saslpay.service.T24DataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service("T24DataService")
|
||||
@Transactional
|
||||
public class T24DataServiceImpl implements T24DataService {
|
||||
|
||||
@Autowired
|
||||
private T24DataRepository t24DataRepository;
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
private Object T24DataEntity;
|
||||
|
||||
// @Override
|
||||
// public T24DataEntity saveT24DataEntity(T24DataEntity t24DataEntity) {
|
||||
// T24DataEntity response = t24DataRepository.save(t24DataEntity);
|
||||
// return response;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public T24DataEntity getT24DataEntity(String id) {
|
||||
// T24DataEntity t24DataEntity = entityManager.find(T24DataEntity.class, id);
|
||||
// return t24DataEntity;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<T24DataEntity> findAll() {
|
||||
return t24DataRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<T24DataEntity> findById(String id) {
|
||||
t24DataRepository.findById(id);
|
||||
return t24DataRepository.findById(id);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Optional<T24DataEntity> deleteById(String id) {
|
||||
// t24DataRepository.deleteById(id);
|
||||
// return Optional.empty();
|
||||
// }
|
||||
//"SELECT * FROM `t24Data` WHERE `customerNo` = '111247'"
|
||||
//"SELECT * FROM `t24Data` WHERE `accountId'` = '01070011124701'
|
||||
|
||||
// @Override
|
||||
// public List<T24DataEntity> deleteAll() {
|
||||
// t24DataRepository.deleteAll();
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// @Override
|
||||
// public T24DataEntity update(T24DataEntity t24DataEntity) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public T24DataEntity save(T24DataEntity t24DataEntity) {
|
||||
t24DataRepository.save(t24DataEntity);
|
||||
return t24DataEntity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.saslpay.impl;
|
||||
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import com.saslpay.repository.TransactionDataRepository;
|
||||
import com.saslpay.service.TransactionDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service("TransactionDataService")
|
||||
@Transactional
|
||||
public class TransactionDataServiceImpl implements TransactionDataService {
|
||||
|
||||
@Autowired
|
||||
private TransactionDataRepository transactionDataRepository;
|
||||
|
||||
@PersistenceContext
|
||||
EntityManager entityManager;
|
||||
|
||||
@Override
|
||||
public TransactionDataEntity saveTransactionDataEntity(TransactionDataEntity transactionDataEntity) {
|
||||
TransactionDataEntity response = transactionDataRepository.save(transactionDataEntity);
|
||||
return response;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionDataEntity getTransactionDataEntity(String id) {
|
||||
TransactionDataEntity transactionDataEntity = entityManager.find(TransactionDataEntity.class,id);
|
||||
return transactionDataEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TransactionDataEntity> findAll() {
|
||||
return transactionDataRepository.findAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TransactionDataEntity> findById(String id) {
|
||||
return transactionDataRepository.findById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Optional<TransactionDataEntity> deleteById(String id) {
|
||||
transactionDataRepository.deleteById(id);
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TransactionDataEntity> deleteAll() {
|
||||
transactionDataRepository.deleteAll();
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionDataEntity update(TransactionDataEntity transactionDataEntity) {
|
||||
transactionDataRepository.save(transactionDataEntity);
|
||||
return transactionDataEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TransactionDataEntity save(TransactionDataEntity transactionDataEntity) {
|
||||
transactionDataRepository.save(transactionDataEntity);
|
||||
return transactionDataEntity;
|
||||
}
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.saslpay.log;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class SaslPayLog {
|
||||
|
||||
public void log(String log){
|
||||
Logger logger = LoggerFactory.getLogger(SaslPayLog.class);
|
||||
logger.info(log);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.saslpay.repository;
|
||||
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface T24DataRepository extends JpaRepository<T24DataEntity, String> {
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.saslpay.repository;
|
||||
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface TransactionDataRepository extends JpaRepository<TransactionDataEntity, String> {
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.saslpay.repository;
|
||||
|
||||
import com.saslpay.entities.UserEntity;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface UserRepository extends CrudRepository<UserEntity, Integer> {
|
||||
|
||||
UserEntity findByUsername(String username);
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.saslpay.service;
|
||||
|
||||
import com.saslpay.entities.T24DataEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface T24DataService {
|
||||
|
||||
// T24DataEntity saveT24DataEntity(T24DataEntity t24DataEntity);
|
||||
|
||||
// T24DataEntity getT24DataEntity(String id);
|
||||
|
||||
List<T24DataEntity> findAll();
|
||||
|
||||
Optional<T24DataEntity> findById(String id);
|
||||
|
||||
// Optional<T24DataEntity> deleteById(String id);
|
||||
|
||||
// List<T24DataEntity> deleteAll();
|
||||
|
||||
// T24DataEntity update(T24DataEntity t24DataEntity);
|
||||
|
||||
T24DataEntity save(T24DataEntity t24DataEntity);
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.saslpay.service;
|
||||
|
||||
|
||||
import com.saslpay.entities.TransactionDataEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
public interface TransactionDataService {
|
||||
|
||||
TransactionDataEntity saveTransactionDataEntity(TransactionDataEntity transactionDataEntity);
|
||||
|
||||
TransactionDataEntity getTransactionDataEntity(String id);
|
||||
|
||||
List<TransactionDataEntity> findAll();
|
||||
|
||||
Optional<TransactionDataEntity> findById(String id);
|
||||
|
||||
Optional<TransactionDataEntity> deleteById(String id);
|
||||
|
||||
List<TransactionDataEntity> deleteAll();
|
||||
|
||||
TransactionDataEntity update(TransactionDataEntity transactionDataEntity);
|
||||
|
||||
TransactionDataEntity save(TransactionDataEntity transactionDataEntity);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user