Subversion Repositories SmartDukaan

Rev

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

Rev 30748 Rev 30889
Line 90... Line 90...
90
		userWalletRepository.persist(userWallet);
90
		userWalletRepository.persist(userWallet);
91
		this.createUserWalletHistory(-Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
91
		this.createUserWalletHistory(-Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
92
	}
92
	}
93
 
93
 
94
	@Override
94
	@Override
-
 
95
	public void consumeAmountFromWallet(int retailerId, int referenceId, WalletReferenceType referenceType,
-
 
96
										String description, float amount, LocalDateTime businessTime, boolean forced) throws ProfitMandiBusinessException {
-
 
97
		if (underMaintainance) {
-
 
98
			throw pbse;
-
 
99
		} else if (WalletReferenceType.RECHARGE.equals(referenceType) && !isActive(retailerId)) {
-
 
100
			throw inactivepbse;
-
 
101
		}
-
 
102
		if (amount == 0)
-
 
103
			return;
-
 
104
		UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
-
 
105
		int walletAmount = walletService.getWalletAmount(retailerId);
-
 
106
		// userWallet = userWalletRepository.selectByIdForUpdate(userWallet.getId());
-
 
107
		if (!forced && amount > 2 && amount > walletAmount) {
-
 
108
			LOGGER.error("Wallet Balance is insufficient!");
-
 
109
			throw new ProfitMandiBusinessException("balance", walletAmount, "WLT_1000");
-
 
110
		}
-
 
111
		userWallet.setAmount(walletAmount - Math.round(amount));
-
 
112
		this.createUserWalletHistory(-Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
-
 
113
	}
-
 
114
 
-
 
115
	@Override
95
	public void rollbackAmountFromWallet(int retailerId, float amountToRollback, int rollbackReference,
116
	public void rollbackAmountFromWallet(int retailerId, float amountToRollback, int rollbackReference,
96
										 WalletReferenceType walletReferenceType, String rollbackReason, LocalDateTime businessTime) throws ProfitMandiBusinessException {
117
										 WalletReferenceType walletReferenceType, String rollbackReason, LocalDateTime businessTime) throws ProfitMandiBusinessException {
97
 
118
 
98
		if (amountToRollback == 0)
119
		if (amountToRollback == 0)
99
			return;
120
			return;