Subversion Repositories SmartDukaan

Rev

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

Rev 32841 Rev 32842
Line 3339... Line 3339...
3339
        data = new String(Files.readAllBytes(Paths.get(file)));
3339
        data = new String(Files.readAllBytes(Paths.get(file)));
3340
        return data;
3340
        return data;
3341
    }
3341
    }
3342
 
3342
 
3343
 
3343
 
3344
 
-
 
3345
    public void partnerWiseCreditAccount() throws Exception {
3344
    public void partnerWiseCreditAccount() throws Exception {
3346
 
3345
 
3347
        List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
3346
        List<FofoStore> fofoStores = fofoStoreRepository.selectActiveStores();
3348
 
3347
 
3349
        for (FofoStore fs : fofoStores) {
3348
        for (FofoStore fs : fofoStores) {
Line 4602... Line 4601...
4602
                    sendMailOfHtmlFormat(mailSender, email, messageText, null, subject);
4601
                    sendMailOfHtmlFormat(mailSender, email, messageText, null, subject);
4603
 
4602
 
4604
                }
4603
                }
4605
            }
4604
            }
4606
        }*/
4605
        }*/
-
 
4606
        //Send single whatsapp to tv
-
 
4607
        String title = "SD Credit Alert!";
-
 
4608
        Loan singLeLoan = defaultLoans.get(0);
-
 
4609
        List<LoanStatement> loanStatements1 = loanStatementRepository.selectByLoanId(singLeLoan.getId());
-
 
4610
        double amount1 = loanStatements1.stream().map(LoanStatement::getAmount).collect(Collectors.summingDouble(BigDecimal::doubleValue));
-
 
4611
        notificationService.sendWhatsappMessage(getWhatsAppMessageForDueDateExtend(singLeLoan, amount1), title, "9911565032");
4607
 
4612
 
4608
        for (Loan defaultLoan : defaultLoans) {
4613
        for (Loan defaultLoan : defaultLoans) {
4609
            List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
4614
            List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(defaultLoan.getId());
4610
 
4615
 
4611
            double amount = loanStatements.stream().map(LoanStatement::getAmount).collect(Collectors.summingDouble(BigDecimal::doubleValue));
4616
            double amount = loanStatements.stream().map(LoanStatement::getAmount).collect(Collectors.summingDouble(BigDecimal::doubleValue));
4612
 
4617
 
4613
            com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
4618
            com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(defaultLoan.getFofoId());
4614
 
4619
 
4615
            Address address = addressRepository.selectById(user.getAddressId());
4620
            Address address = addressRepository.selectById(user.getAddressId());
4616
 
4621
 
4617
            String title = "Alert!";
-
 
4618
            String url = "http://app.smartdukaan.com/pages/home/credit";
4622
            //String url = "http://app.smartdukaan.com/pages/home/credit";
4619
 
4623
 
4620
            String message = getMessageForDueDateExtend(defaultLoan,amount);
4624
            String message = getMessageForDueDateExtend(defaultLoan, amount);
4621
            String whatsAppMessage = getWhatsAppMessageForDueDateExtend(defaultLoan,amount);
4625
            String whatsAppMessage = getWhatsAppMessageForDueDateExtend(defaultLoan, amount);
4622
            notificationService.sendWhatsappMessage(whatsAppMessage, title, address.getPhoneNumber());
4626
            notificationService.sendWhatsappMessage(whatsAppMessage, title, address.getPhoneNumber());
4623
            String[] email = {user.getEmailId()};
4627
            String[] email = {user.getEmailId()};
4624
            sendMailOfHtmlFormat(mailSender, email, message, null, "Loan Alert - SmartDukaan");
4628
            sendMailOfHtmlFormat(mailSender, email, message, null, "Loan Alert - SmartDukaan");
4625
        }
4629
        }
4626
    }
4630
    }
Line 4638... Line 4642...
4638
        String name = userUserRepository.selectById(defaultLoan.getFofoId()).getName();
4642
        String name = userUserRepository.selectById(defaultLoan.getFofoId()).getName();
4639
 
4643
 
4640
        // Initialize a StringBuilder to construct the HTML message
4644
        // Initialize a StringBuilder to construct the HTML message
4641
        StringBuilder sb = new StringBuilder();
4645
        StringBuilder sb = new StringBuilder();
4642
 
4646
 
4643
        if(LocalDate.now().isBefore(dueDate)){
4647
        if (LocalDate.now().isBefore(dueDate)) {
4644
            long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now() , defaultLoan.getDueDate().toLocalDate());
4648
            long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), defaultLoan.getDueDate().toLocalDate());
4645
            String payDate = defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
4649
            String payDate = defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
4646
            // 5 Days Before Due Date - daily
4650
            // 5 Days Before Due Date - daily
4647
            if (noOfdaysBetween <= 5) {
4651
            if (noOfdaysBetween <= 5) {
4648
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
4652
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
4649
                sb.append("<p>This is a friendly reminder that your loan payment is due in " + noOfdaysBetween + "days, on " +
4653
                sb.append("<p>This is a friendly reminder that your loan payment is due in " + noOfdaysBetween + "days, on " +
Line 4652... Line 4656...
4652
                sb.append("<p>As per the terms of your loan agreement, the total amount due is Rs. " + formattedAmount + ". " +
4656
                sb.append("<p>As per the terms of your loan agreement, the total amount due is Rs. " + formattedAmount + ". " +
4653
                        "You can make the payment by adding money to your wallet. If you have any questions or need assistance, " +
4657
                        "You can make the payment by adding money to your wallet. If you have any questions or need assistance, " +
4654
                        "our customer service team is available to help you.</p>");
4658
                        "our customer service team is available to help you.</p>");
4655
                sb.append("<p>Thank you for your cooperation and prompt attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4659
                sb.append("<p>Thank you for your cooperation and prompt attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4656
            }
4660
            }
4657
        }else if(LocalDate.now().isBefore(defaultDate)){
4661
        } else if (LocalDate.now().isBefore(defaultDate)) {
4658
            long noOfdaysBetween = ChronoUnit.DAYS.between(defaultDate, LocalDate.now());
4662
            long noOfdaysBetween = ChronoUnit.DAYS.between(defaultDate, LocalDate.now());
4659
 
4663
 
4660
            // After Due Date – Alternate days
4664
            // After Due Date – Alternate days
4661
            if ((noOfdaysBetween % 2 == 0) && (noOfdaysBetween > 5)) {
4665
            if ((noOfdaysBetween % 2 == 0) && (noOfdaysBetween > 5)) {
4662
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
4666
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
Line 4665... Line 4669...
4665
                sb.append("<p>To avoid further charges and any negative impact on your CIBIL score, we kindly request that you settle the " +
4669
                sb.append("<p>To avoid further charges and any negative impact on your CIBIL score, we kindly request that you settle the " +
4666
                        "outstanding balance as soon as possible.</p>");
4670
                        "outstanding balance as soon as possible.</p>");
4667
                sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4671
                sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4668
            }
4672
            }
4669
            // 5 Days before default - daily
4673
            // 5 Days before default - daily
4670
            if (noOfdaysBetween <= 5 ) {
4674
            if (noOfdaysBetween <= 5) {
4671
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br>");
4675
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br>");
4672
                sb.append("<p>Attention: High Alert</p>");
4676
                sb.append("<p>Attention: High Alert</p>");
4673
                sb.append("<p>Dear " + name + "</p>");
4677
                sb.append("<p>Dear " + name + "</p>");
4674
                sb.append("<p>This is to inform you that the due date for your payment of Rs. " + formattedAmount + " has been crossed, " +
4678
                sb.append("<p>This is to inform you that the due date for your payment of Rs. " + formattedAmount + " has been crossed, " +
4675
                        "and you are approaching the default date on " + defaultDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ". " +
4679
                        "and you are approaching the default date on " + defaultDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ". " +
4676
                        "Please be aware that this will have a significant impact on your CIBIL score and may result in substantial penalties as well.</p>");
4680
                        "Please be aware that this will have a significant impact on your CIBIL score and may result in substantial penalties as well.</p>");
4677
                sb.append("<p>To rectify this situation, it is imperative that you take immediate action. " +
4681
                sb.append("<p>To rectify this situation, it is imperative that you take immediate action. " +
4678
                        "Please make the necessary payment immediately to avoid further consequences.</p>");
4682
                        "Please make the necessary payment immediately to avoid further consequences.</p>");
4679
                sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4683
                sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4680
            }
4684
            }
4681
        }else{
4685
        } else {
4682
            // Post Default - Daily
4686
            // Post Default - Daily
4683
                sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
4687
            sb.append("<html><body><p><b>Loan Repayment Alert !</b></p></br><p>Dear " + name + "</p>");
4684
                sb.append("<p>We regret to inform you that you are currently in loan default. As a result, " +
4688
            sb.append("<p>We regret to inform you that you are currently in loan default. As a result, " +
4685
                        "higher penalties are being charged, which is also negatively impacting your CIBIL score. " +
4689
                    "higher penalties are being charged, which is also negatively impacting your CIBIL score. " +
4686
                        "It is imperative that you make an immediate payment to rectify this situation.</p>");
4690
                    "It is imperative that you make an immediate payment to rectify this situation.</p>");
4687
                sb.append("<p>Please note that failing to make the payment promptly will result in further consequences, " +
4691
            sb.append("<p>Please note that failing to make the payment promptly will result in further consequences, " +
4688
                        "including potential legal action and additional financial penalties. " +
4692
                    "including potential legal action and additional financial penalties. " +
4689
                        "We strongly urge you to take this matter seriously and settle the outstanding amount as soon as possible.</p>");
4693
                    "We strongly urge you to take this matter seriously and settle the outstanding amount as soon as possible.</p>");
4690
                sb.append("<p>To make the payment, please add Rs. " + formattedAmount + " to your wallet. We are here to help you resolve this issue and get back on track.</p>");
4694
            sb.append("<p>To make the payment, please add Rs. " + formattedAmount + " to your wallet. We are here to help you resolve this issue and get back on track.</p>");
4691
                sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4695
            sb.append("<p>Thank you for your attention to this matter.</p></br><p> Smart Dukaan Team !!</p>");
4692
 
4696
 
4693
        }
4697
        }
4694
 
4698
 
4695
        // Return the constructed HTML message
4699
        // Return the constructed HTML message
4696
        sb.append("</body></html>");
4700
        sb.append("</body></html>");
Line 4710... Line 4714...
4710
        String name = userUserRepository.selectById(defaultLoan.getFofoId()).getName();
4714
        String name = userUserRepository.selectById(defaultLoan.getFofoId()).getName();
4711
 
4715
 
4712
        // Initialize a StringBuilder to construct the HTML message
4716
        // Initialize a StringBuilder to construct the HTML message
4713
        String message = null;
4717
        String message = null;
4714
 
4718
 
4715
        if(LocalDate.now().isBefore(dueDate)){
4719
        if (LocalDate.now().isBefore(dueDate)) {
4716
            long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), defaultLoan.getDueDate().toLocalDate());
4720
            long noOfdaysBetween = ChronoUnit.DAYS.between(LocalDate.now(), defaultLoan.getDueDate().toLocalDate());
4717
            String payDate = defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
4721
            String payDate = defaultLoan.getDueDate().toLocalDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
4718
            // 5 Days Before Due Date - daily
4722
            // 5 Days Before Due Date - daily
4719
            if (noOfdaysBetween <= 5) {
4723
            if (noOfdaysBetween <= 5) {
4720
 
4724
 
Line 4724... Line 4728...
4724
                        "\n" +
4728
                        "\n" +
4725
                        "If you have any questions or need assistance, our customer service team is available to help you.\n" +
4729
                        "If you have any questions or need assistance, our customer service team is available to help you.\n" +
4726
                        "Thank you for your cooperation and prompt attention to this matter.\n" +
4730
                        "Thank you for your cooperation and prompt attention to this matter.\n" +
4727
                        "\n" +
4731
                        "\n" +
4728
                        "Team SmartDukaan";
4732
                        "Team SmartDukaan";
4729
                message = String.format(message, name, noOfdaysBetween, payDate,formattedAmount);
4733
                message = String.format(message, name, noOfdaysBetween, payDate, formattedAmount);
4730
                  }
4734
            }
4731
        }else if(LocalDate.now().isBefore(defaultDate)){
4735
        } else if (LocalDate.now().isBefore(defaultDate)) {
4732
            long noOfdaysBetween = ChronoUnit.DAYS.between(defaultDate, LocalDate.now());
4736
            long noOfdaysBetween = ChronoUnit.DAYS.between(defaultDate, LocalDate.now());
4733
            // After Due Date – Alternate days
4737
            // After Due Date – Alternate days
4734
            if ((noOfdaysBetween % 2 == 0) && (noOfdaysBetween > 5)) {
4738
            if ((noOfdaysBetween % 2 == 0) && (noOfdaysBetween > 5)) {
4735
                message = "Dear %s, We would like to remind you that your payment for the outstanding balance on your account is now overdue. \n" +
4739
                message = "Dear %s, We would like to remind you that your payment for the outstanding balance on your account is now overdue. \n" +
4736
                        "As per our terms and conditions, a higher interest rate will be levied on the overdue amount Rs.%s.\n" +
4740
                        "As per our terms and conditions, a higher interest rate will be levied on the overdue amount Rs.%s.\n" +
Line 4739... Line 4743...
4739
                        "\n" +
4743
                        "\n" +
4740
                        "Team SmartDukaan";
4744
                        "Team SmartDukaan";
4741
                message = String.format(message, name, formattedAmount);
4745
                message = String.format(message, name, formattedAmount);
4742
            }
4746
            }
4743
            // 5 Days before default - daily
4747
            // 5 Days before default - daily
4744
            if (noOfdaysBetween <= 5 ) {
4748
            if (noOfdaysBetween <= 5) {
4745
                String defaultPayDate = defaultDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
4749
                String defaultPayDate = defaultDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"));
4746
                message = "Attention: High Alert!! Dear %s, \n" +
4750
                message = "Attention: High Alert!! Dear %s, \n" +
4747
                        "\n" +
4751
                        "\n" +
4748
                        "This is to inform you that the due date for your payment of Rs. %s has been crossed, and as a result, you are now about to reach default date %s.\n" +
4752
                        "This is to inform you that the due date for your payment of Rs. %s has been crossed, and as a result, you are now about to reach default date %s.\n" +
4749
                        "Please be aware that this will have a significant impact on your CIBIL score and may result in substantial penalties as well. To rectify this situation, it is imperative that you take immediate action.\n" +
4753
                        "Please be aware that this will have a significant impact on your CIBIL score and may result in substantial penalties as well. To rectify this situation, it is imperative that you take immediate action.\n" +
Line 4751... Line 4755...
4751
                        "Please make the necessary payment immediately to avoid further consequences. Thank you for your attention to this matter.\n" +
4755
                        "Please make the necessary payment immediately to avoid further consequences. Thank you for your attention to this matter.\n" +
4752
                        "\n" +
4756
                        "\n" +
4753
                        "Team SmartDukaan";
4757
                        "Team SmartDukaan";
4754
                message = String.format(message, name, formattedAmount, defaultPayDate);
4758
                message = String.format(message, name, formattedAmount, defaultPayDate);
4755
            }
4759
            }
4756
        }else {
4760
        } else {
4757
            // Post Default - Daily
4761
            // Post Default - Daily
4758
            message = "Dear %s, We regret to inform you that you are currently in loan default. As a result, higher penalties are being charged, which is also negatively impacting your CIBIL score. \n" +
4762
            message = "Dear %s, We regret to inform you that you are currently in loan default. As a result, higher penalties are being charged, which is also negatively impacting your CIBIL score. \n" +
4759
                    "\n" +
4763
                    "\n" +
4760
                    "It is imperative that you make an immediate payment to rectify this situation. \n" +
4764
                    "It is imperative that you make an immediate payment to rectify this situation. \n" +
4761
                    "\n" +
4765
                    "\n" +