Subversion Repositories SmartDukaan

Rev

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

Rev 33848 Rev 33861
Line 4... Line 4...
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
5
import com.spice.profitmandi.common.model.ProfitMandiConstants;
5
import com.spice.profitmandi.common.model.ProfitMandiConstants;
6
import com.spice.profitmandi.common.util.FormattingUtils;
6
import com.spice.profitmandi.common.util.FormattingUtils;
7
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
7
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
8
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
8
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
9
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
-
 
10
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
9
import com.spice.profitmandi.dao.entity.transaction.ManualPaymentType;
11
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
10
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
12
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
11
import com.spice.profitmandi.dao.entity.transaction.UserWalletHistory;
13
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
12
import com.spice.profitmandi.dao.enumuration.dtr.AccountType;
14
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
13
import com.spice.profitmandi.dao.repository.catalog.ManualPaymentRequestRepository;
Line 76... Line 75...
76
        userWallet.setAmount(walletAmount + Math.round(amount));
75
        userWallet.setAmount(walletAmount + Math.round(amount));
77
        if (amount > 0) {
76
        if (amount > 0) {
78
            notificationService.sendNotification(retailerId, "walletcredit", MessageType.wallet, "Rs." + FormattingUtils.formatDecimal(amount) + " credited in SD Wallet", description);
77
            notificationService.sendNotification(retailerId, "walletcredit", MessageType.wallet, "Rs." + FormattingUtils.formatDecimal(amount) + " credited in SD Wallet", description);
79
        }
78
        }
80
        this.createUserWalletHistory(Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
79
        this.createUserWalletHistory(Math.round(amount), userWallet.getId(), referenceId, referenceType, description, businessTime);
81
//        this.checkFullStockPayment(userWallet.getId(), retailerId);
-
 
82
    }
-
 
83
 
-
 
84
    private void checkFullStockPayment(int walletId, int retailerId) throws ProfitMandiBusinessException {
-
 
85
        List<UserWalletHistory> userWalletHistories = userWalletHistoryRepository.selectByWalletIdAndReferenceType(walletId, WalletReferenceType.ADVANCE_AMOUNT);
-
 
86
        long totalAdvanceAmount = userWalletHistories.stream().mapToLong(x -> x.getAmount()).sum();
-
 
87
        LOGGER.info("totalAdvanceAmount - " + totalAdvanceAmount);
-
 
88
        if (totalAdvanceAmount >= ProfitMandiConstants.MIN_FULL_STOCK_PAYMENT) {
-
 
89
            PartnerOnBoardingPanel pop = partnerOnBoardingPanelRepository.selectByCode(fofoStoreRepository.selectByRetailerId(retailerId).getCode());
-
 
90
            storeTimelineTatService.onFullPaymentReceived(pop.getId());
-
 
91
        }
-
 
92
    }
80
    }
93
 
81
 
94
    @Override
82
    @Override
95
    public void consumeAmountFromWallet(int retailerId, int referenceId, WalletReferenceType referenceType,
83
    public void consumeAmountFromWallet(int retailerId, int referenceId, WalletReferenceType referenceType,
96
                                        String description, float amount, LocalDateTime businessTime) throws ProfitMandiBusinessException {
84
                                        String description, float amount, LocalDateTime businessTime) throws ProfitMandiBusinessException {