Subversion Repositories SmartDukaan

Rev

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

Rev 34729 Rev 34731
Line 1107... Line 1107...
1107
        }
1107
        }
1108
    }
1108
    }
1109
 
1109
 
1110
 
1110
 
1111
    public void test() throws Exception {
1111
    public void test() throws Exception {
-
 
1112
        this.fixBlockedCredit();
1112
        //Utils.sendMailWithAttachments( mailSender,"amit.gupta@smartdukaan.com", null, "Hello World!", "Test Mail", null);
1113
        //Utils.sendMailWithAttachments( mailSender,"amit.gupta@smartdukaan.com", null, "Hello World!", "Test Mail", null);
1113
        //sdCreditService.updateRisk();
1114
        //sdCreditService.updateRisk();
1114
        PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(175139309,
1115
        PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(175139309,
1115
                YearMonth.of(2025, 5).atDay(1));
1116
                YearMonth.of(2025, 5).atDay(1));
1116
        System.out.println(partnerType);
1117
        System.out.println(partnerType);
Line 1144... Line 1145...
1144
        System.out.println(response);
1145
        System.out.println(response);
1145
 
1146
 
1146
        Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");*/
1147
        Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");*/
1147
    }
1148
    }
1148
 
1149
 
-
 
1150
    @Autowired
-
 
1151
    LoanTransactionRepository loanTransactionRepository;
-
 
1152
 
-
 
1153
    private void fixBlockedCredit() throws ProfitMandiBusinessException {
-
 
1154
        List<Loan> unsettledBlockedLoans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() >= 365).collect(toList());
-
 
1155
        //unsettledBlockedLoans = unsettledBlockedLoans.stream().filter(x -> x.getId() == 52310).collect(toList());
-
 
1156
        for (Loan unsettledBlockedLoan : unsettledBlockedLoans) {
-
 
1157
            LoanTransaction loanTransaction = loanTransactionRepository.selectByLoanId(unsettledBlockedLoan.getId());
-
 
1158
            if (loanTransaction == null) {
-
 
1159
                System.out.println("Cant find Transaction Id for Loan - " + unsettledBlockedLoan.getId() + "-- Created On ->" + unsettledBlockedLoan.getCreatedOn());
-
 
1160
                continue;
-
 
1161
            }
-
 
1162
            List<Order> processedOrders = orderRepository.selectAllByTransactionId(loanTransaction.getTransactionId()).stream()
-
 
1163
                    .filter(x -> !x.getStatus().equals(OrderStatus.SUBMITTED_FOR_PROCESSING)).collect(toList());
-
 
1164
            List<OrderStatus> processedOrderIds = processedOrders.stream().map(x -> x.getStatus()).collect(Collectors.toList());
-
 
1165
            System.out.println("processedOrderIds " + processedOrderIds);
-
 
1166
            //if(unsettledBlockedLoan !=null) continue;
-
 
1167
            double limitToRelease = processedOrders.stream().collect(Collectors.summingDouble(x -> x.getWalletAmount()));
-
 
1168
            sdCreditService.releaseBlockedLimit(unsettledBlockedLoan, limitToRelease);
-
 
1169
 
-
 
1170
 
-
 
1171
        }
-
 
1172
    }
-
 
1173
 
1149
    public static byte[] toByteArray(InputStream input) throws IOException {
1174
    public static byte[] toByteArray(InputStream input) throws IOException {
1150
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
1175
        ByteArrayOutputStream buffer = new ByteArrayOutputStream();
1151
        int nRead;
1176
        int nRead;
1152
        byte[] data = new byte[16384];
1177
        byte[] data = new byte[16384];
1153
        while ((nRead = input.read(data, 0, data.length)) != -1) {
1178
        while ((nRead = input.read(data, 0, data.length)) != -1) {
Line 3813... Line 3838...
3813
 
3838
 
3814
            Address address = addressRepository.selectById(user.getAddressId());
3839
            Address address = addressRepository.selectById(user.getAddressId());
3815
 
3840
 
3816
            String title = "Outstanding Credit Payment Overdue!";
3841
            String title = "Outstanding Credit Payment Overdue!";
3817
            String url = "http://app.smartdukaan.com/pages/home/credit";
3842
            String url = "http://app.smartdukaan.com/pages/home/credit";
3818
            String message = "Your Outstanding Credit payment due date " + defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " has been exceeded. Please note "+ ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE +" shall be levied on daily basis." + " Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
3843
            String message = "Your Outstanding Credit payment due date " + defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " has been exceeded. Please note " + ProfitMandiConstants.NEW_DELAYED_INTEREST_RATE + " shall be levied on daily basis." + " Your total pending Loan amount is Rs." + FormattingUtils.formatDecimal(Math.abs(amount)) + ". !!Pay Now!!";
3819
            notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title, message, url);
3844
            notificationService.sendNotification(defaultLoan.getFofoId(), title, MessageType.notification, title, message, url);
3820
 
3845
 
3821
            // notificationService.sendWhatsappMessage(message, title,
3846
            // notificationService.sendWhatsappMessage(message, title,
3822
            // address.getPhoneNumber());
3847
            // address.getPhoneNumber());
3823
 
3848