| Line 105... |
Line 105... |
| 105 |
return;
|
105 |
return;
|
| 106 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
106 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
| 107 |
int walletAmount = this.getWalletAmount(retailerId);
|
107 |
int walletAmount = this.getWalletAmount(retailerId);
|
| 108 |
// userWallet = userWalletRepository.selectByIdForUpdate(userWallet.getId());
|
108 |
// userWallet = userWalletRepository.selectByIdForUpdate(userWallet.getId());
|
| 109 |
if (!WalletReferenceType.DAMAGE_PROTECTION.equals(referenceType) && amount > ProfitMandiConstants.MAX_NEGATIVE_WALLET_VALUE && Math.floor(amount) > walletAmount) {
|
109 |
if (!WalletReferenceType.DAMAGE_PROTECTION.equals(referenceType) && amount > ProfitMandiConstants.MAX_NEGATIVE_WALLET_VALUE && Math.floor(amount) > walletAmount) {
|
| 110 |
LOGGER.error("Wallet Balance is insufficient!, needed - {}, wallet has - {}", Math.floor(amount), walletAmount);
|
110 |
LOGGER.error("Wallet Balance is insufficient!, needed - {}, wallet has - {}, for retailer - {}", Math.floor(amount), walletAmount, retailerId);
|
| 111 |
throw new ProfitMandiBusinessException("balance", walletAmount, "WLT_1000");
|
111 |
throw new ProfitMandiBusinessException("balance", walletAmount, "WLT_1000");
|
| 112 |
}
|
112 |
}
|
| 113 |
userWallet.setAmount(walletAmount - Math.round(amount));
|
113 |
userWallet.setAmount(walletAmount - Math.round(amount));
|
| 114 |
userWalletRepository.persist(userWallet);
|
114 |
userWalletRepository.persist(userWallet);
|
| 115 |
this.createUserWalletHistory(-Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
|
115 |
this.createUserWalletHistory(-Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
|