Subversion Repositories SmartDukaan

Rev

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

Rev 32494 Rev 32871
Line 81... Line 81...
81
            return;
81
            return;
82
        UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
82
        UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
83
        int walletAmount = walletService.getWalletAmount(retailerId);
83
        int walletAmount = walletService.getWalletAmount(retailerId);
84
        // userWallet = userWalletRepository.selectByIdForUpdate(userWallet.getId());
84
        // userWallet = userWalletRepository.selectByIdForUpdate(userWallet.getId());
85
        if (!WalletReferenceType.DAMAGE_PROTECTION.equals(referenceType) && amount > 2 && Math.floor(amount) > walletAmount) {
85
        if (!WalletReferenceType.DAMAGE_PROTECTION.equals(referenceType) && amount > 2 && Math.floor(amount) > walletAmount) {
86
            LOGGER.error("Wallet Balance is insufficient!");
86
            LOGGER.error("Wallet Balance is insufficient!, needed - {}, wallet has - {}", Math.floor(amount), walletAmount);
87
            throw new ProfitMandiBusinessException("balance", walletAmount, "WLT_1000");
87
            throw new ProfitMandiBusinessException("balance", walletAmount, "WLT_1000");
88
        }
88
        }
89
        userWallet.setAmount(walletAmount - Math.round(amount));
89
        userWallet.setAmount(walletAmount - Math.round(amount));
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);