Subversion Repositories SmartDukaan

Rev

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

Rev 34982 Rev 35197
Line 456... Line 456...
456
        }
456
        }
457
 
457
 
458
        return "add-wallet-request-paginated";
458
        return "add-wallet-request-paginated";
459
    }
459
    }
460
 
460
 
-
 
461
    @Autowired
-
 
462
    HdfcPaymentRepository hdfcPaymentRepository;
-
 
463
 
461
    @RequestMapping(value = "/addAmountToWallet", method = RequestMethod.PUT)
464
    @RequestMapping(value = "/addAmountToWallet", method = RequestMethod.PUT)
462
    public String addAmountToWallet(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, @RequestParam(name = "walletRequestid", defaultValue = "0") int walletRequestid, Model model) throws Exception {
465
    public String addAmountToWallet(HttpServletRequest request, @RequestParam(name = "id", defaultValue = "0") int id, @RequestParam(name = "walletRequestid", defaultValue = "0") int walletRequestid, Model model) throws Exception {
463
 
466
 
464
        AddWalletRequest addWalletRequest = addWalletRequestRepository.selectById(walletRequestid);
467
        AddWalletRequest addWalletRequest = addWalletRequestRepository.selectById(walletRequestid);
-
 
468
        List<AddWalletRequest> requests = addWalletRequestRepository.selectAllByTransactionReference(addWalletRequest.getTransaction_reference());
-
 
469
        if (requests.stream().filter(x -> x.getId() != addWalletRequest.getId()).filter(x -> x.getStatus().equals(approved)).count() != 1) {
-
 
470
            HdfcPayment hdfcPayment = hdfcPaymentRepository.selectByUtrNo(addWalletRequest.getTransaction_reference());
-
 
471
            if (hdfcPayment != null) {
-
 
472
                String rejectReason = "Payment for UTR Already added via Auto Update";
-
 
473
                throw new ProfitMandiBusinessException(rejectReason, rejectReason, rejectReason);
-
 
474
            }
-
 
475
        } else {
-
 
476
            String rejectReason = "Entry already Approved Please reject";
-
 
477
            throw new ProfitMandiBusinessException(rejectReason, rejectReason, rejectReason);
-
 
478
        }
465
        if (addWalletRequest.getStatus().equals(AddWalletRequestStatus.pending)) {
479
        if (addWalletRequest.getStatus().equals(AddWalletRequestStatus.pending)) {
466
            walletService.addAmountToWallet(addWalletRequest.getRetailerId(), walletRequestid, WalletReferenceType.ADVANCE_AMOUNT, "ntfs/rgfs", addWalletRequest.getAmount(), addWalletRequest.getCreateTimestamp());
480
            walletService.addAmountToWallet(addWalletRequest.getRetailerId(), walletRequestid, WalletReferenceType.ADVANCE_AMOUNT, "ntfs/rgfs", addWalletRequest.getAmount(), addWalletRequest.getCreateTimestamp());
467
            addWalletRequest.setStatus(AddWalletRequestStatus.approved);
481
            addWalletRequest.setStatus(AddWalletRequestStatus.approved);
468
            addWalletRequest.setUpdateTimestamp(LocalDateTime.now());
482
            addWalletRequest.setUpdateTimestamp(LocalDateTime.now());
469
            addWalletRequestRepository.persist(addWalletRequest);
483
            addWalletRequestRepository.persist(addWalletRequest);
Line 1055... Line 1069...
1055
        model.addAttribute("response1", mvcResponseSender.createResponseString(reference));
1069
        model.addAttribute("response1", mvcResponseSender.createResponseString(reference));
1056
        return "response";
1070
        return "response";
1057
 
1071
 
1058
    }
1072
    }
1059
 
1073
 
1060
    @Autowired
-
 
1061
    HdfcPaymentRepository hdfcPaymentRepository;
-
 
1062
 
-
 
1063
    @RequestMapping(value = "/addMoney", method = RequestMethod.POST)
1074
    @RequestMapping(value = "/addMoney", method = RequestMethod.POST)
1064
    public String addMoney(HttpServletRequest request, @RequestParam float amount, @RequestParam String transactionReference, @RequestParam LocalDateTime referenceTime, @RequestParam String bankName, @RequestParam int fofoId, Model model) throws Exception {
1075
    public String addMoney(HttpServletRequest request, @RequestParam float amount, @RequestParam String transactionReference, @RequestParam LocalDateTime referenceTime, @RequestParam String bankName, @RequestParam int fofoId, Model model) throws Exception {
1065
        transactionReference = transactionReference.toUpperCase().trim();
1076
        transactionReference = transactionReference.toUpperCase().trim();
1066
        List<AddWalletRequest> addWalletRequests = addWalletRequestRepository.selectByReference(transactionReference);
1077
        List<AddWalletRequest> addWalletRequests = addWalletRequestRepository.selectByReference(transactionReference);
1067
        addWalletRequests = addWalletRequests.stream().filter(x -> Arrays.asList(approved, AddWalletRequestStatus.pending).contains(x.getStatus())).collect(Collectors.toList());
1078
        addWalletRequests = addWalletRequests.stream().filter(x -> Arrays.asList(approved, AddWalletRequestStatus.pending).contains(x.getStatus())).collect(Collectors.toList());