| Line 639... |
Line 639... |
| 639 |
throws Exception {
|
639 |
throws Exception {
|
| 640 |
|
640 |
|
| 641 |
List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository
|
641 |
List<UserWalletHistory> userWalletHistory = userWalletHistoryRepository
|
| 642 |
.selectAllByreferenceIdandreferenceType(reference, referenceType);
|
642 |
.selectAllByreferenceIdandreferenceType(reference, referenceType);
|
| 643 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
643 |
UserWallet userWallet = userWalletRepository.selectByRetailerId(retailerId);
|
| - |
|
644 |
int walletAmount = walletService.getWalletAmount(retailerId);
|
| 644 |
|
645 |
|
| 645 |
if (!userWalletHistory.isEmpty()) {
|
646 |
if (!userWalletHistory.isEmpty()) {
|
| 646 |
int WalletId = userWalletHistory.get(0).getWalletId();
|
647 |
int WalletId = userWalletHistory.get(0).getWalletId();
|
| 647 |
UserWallet user = userWalletRepository.selectById(WalletId);
|
648 |
UserWallet user = userWalletRepository.selectById(WalletId);
|
| 648 |
if (retailerId != user.getUserId()) {
|
649 |
if (retailerId != user.getUserId()) {
|
| 649 |
throw new ProfitMandiBusinessException("RefrenceId", reference,
|
650 |
throw new ProfitMandiBusinessException("RefrenceId", reference,
|
| 650 |
"Reference Id assign to Other partner");
|
651 |
"Reference Id assign to Other partner");
|
| 651 |
}
|
652 |
}
|
| 652 |
UserWalletHistory history = new UserWalletHistory();
|
653 |
UserWalletHistory history = new UserWalletHistory();
|
| 653 |
if (TransactionType.CREDIT.equals(transactiontype)) {
|
654 |
if (TransactionType.CREDIT.equals(transactiontype)) {
|
| 654 |
userWallet.setAmount(userWallet.getAmount() + amount);
|
655 |
userWallet.setAmount(walletAmount + amount);
|
| 655 |
history.setAmount(amount);
|
656 |
history.setAmount(amount);
|
| 656 |
history.setDescription(description);
|
657 |
history.setDescription(description);
|
| 657 |
history.setReference(reference);
|
658 |
history.setReference(reference);
|
| 658 |
history.setWalletId(userWallet.getId());
|
659 |
history.setWalletId(userWallet.getId());
|
| 659 |
history.setReferenceType(referenceType);
|
660 |
history.setReferenceType(referenceType);
|
| 660 |
history.setTimestamp(LocalDateTime.now());
|
661 |
history.setTimestamp(LocalDateTime.now());
|
| 661 |
|
662 |
|
| 662 |
} else if (TransactionType.DEBIT.equals(transactiontype)) {
|
663 |
} else if (TransactionType.DEBIT.equals(transactiontype)) {
|
| 663 |
userWallet.setAmount(userWallet.getAmount() - amount);
|
664 |
userWallet.setAmount(walletAmount - amount);
|
| 664 |
history.setAmount(-amount);
|
665 |
history.setAmount(-amount);
|
| 665 |
history.setDescription(description);
|
666 |
history.setDescription(description);
|
| 666 |
history.setWalletId(userWallet.getId());
|
667 |
history.setWalletId(userWallet.getId());
|
| 667 |
history.setReference(reference);
|
668 |
history.setReference(reference);
|
| 668 |
history.setReferenceType(referenceType);
|
669 |
history.setReferenceType(referenceType);
|