Rev 22550 | Rev 22857 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
package com.spice.profitmandi.service.wallet;import java.time.LocalDateTime;import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Component;import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;import com.spice.profitmandi.dao.entity.dtr.UserAccounts;import com.spice.profitmandi.dao.entity.transaction.UserWallet;import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;import com.spice.profitmandi.dao.enumuration.dtr.AccountType;import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;import com.spice.profitmandi.dao.repository.transaction.UserWalletHistoryRepository;import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;@Componentpublic class WalletServiceImpl implements WalletService {@AutowiredUserAccountRepository userAccountRepository;@AutowiredUserWalletRepository userWalletRepository;@AutowiredUserWalletHistoryRepository userWalletHistoryRepository;@Overridepublic UserWallet getUserWalletByUserId(int userId) throws ProfitMandiBusinessException {UserAccounts userAccount = userAccountRepository.getUserAccountByType(userId, AccountType.saholic);Integer retailerId = Integer.valueOf(userAccount.getAccount_key());try {return userWalletRepository.selectByRetailerId(retailerId);} catch (ProfitMandiBusinessException pbe) {UserWallet uw = new UserWallet();uw.setAmount(0);uw.setRefundableAmount(0);uw.setUserId(retailerId);return uw;}}@Overridepublic List<UserWalletHistory> getUserWalletHistoryByUserId(int userId) throws ProfitMandiBusinessException {UserWallet userWallet = this.getUserWalletByUserId(userId);List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectByWalletId(userWallet.getId());return userWalletHistories;}@Overridepublic List<UserWalletHistory> getUserWalletHistoryByRetailerId(int retailerId)throws ProfitMandiBusinessException {UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);return userWalletHistoryRepository.selectByWalletId(userWallet.getId());}@Overridepublic long getSizeByRetailerId(int retailerId, LocalDateTime startDateTime, LocalDateTime endDateTime) throws ProfitMandiBusinessException{UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);return userWalletHistoryRepository.selectCountByWalletId(userWallet.getId(), startDateTime, endDateTime);}@Overridepublic List<UserWalletHistory> getPaginatedUserWalletHistoryByRetailerId(int retailerId,LocalDateTime startDateTime, LocalDateTime endDateTime, int offset, int limit)throws ProfitMandiBusinessException {UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);return userWalletHistoryRepository.selectPaginatedByWalletId(userWallet.getId(), startDateTime, endDateTime, offset, limit);}}