Subversion Repositories SmartDukaan

Rev

Rev 30740 | Rev 30742 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30740 Rev 30741
Line 31... Line 31...
31
	private static final Logger LOGGER = LogManager.getLogger(WalletServiceImpl.class);
31
	private static final Logger LOGGER = LogManager.getLogger(WalletServiceImpl.class);
32
 
32
 
33
	private boolean underMaintainance = false;
33
	private boolean underMaintainance = false;
34
	ProfitMandiBusinessException pbse = new ProfitMandiBusinessException("Wallet", "Wallet",
34
	ProfitMandiBusinessException pbse = new ProfitMandiBusinessException("Wallet", "Wallet",
35
			"Wallet is under maintainance, please try after some time");
35
			"Wallet is under maintainance, please try after some time");
-
 
36
	ProfitMandiBusinessException inactivepbse = new ProfitMandiBusinessException("Wallet", "Wallet",
-
 
37
			"Investment is incomplete, please add amount to wallet to complete the investment");
36
 
38
 
37
	@Autowired
39
	@Autowired
38
	private UserAccountRepository userAccountRepository;
40
	private UserAccountRepository userAccountRepository;
39
 
41
 
40
	@Autowired
42
	@Autowired
Line 68... Line 70...
68
	}
70
	}
69
 
71
 
70
	@Override
72
	@Override
71
	public void consumeAmountFromWallet(int retailerId, int referenceId, WalletReferenceType referenceType,
73
	public void consumeAmountFromWallet(int retailerId, int referenceId, WalletReferenceType referenceType,
72
										String description, float amount, LocalDateTime businessTime) throws ProfitMandiBusinessException {
74
										String description, float amount, LocalDateTime businessTime) throws ProfitMandiBusinessException {
73
		if ((underMaintainance && referenceType.equals(WalletReferenceType.PURCHASE) || !isActive(retailerId))) {
75
		if (underMaintainance) {
74
			throw pbse;
76
			throw pbse;
-
 
77
		} else if (!isActive(retailerId)) {
-
 
78
			throw inactivepbse;
75
		}
79
		}
76
		if (amount == 0)
80
		if (amount == 0)
77
			return;
81
			return;
78
		UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
82
		UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
79
		int walletAmount = walletService.getWalletAmount(retailerId);
83
		int walletAmount = walletService.getWalletAmount(retailerId);