| Line 124... |
Line 124... |
| 124 |
import org.springframework.beans.factory.annotation.Autowired;
|
124 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 125 |
import org.springframework.beans.factory.annotation.Qualifier;
|
125 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 126 |
import org.springframework.beans.factory.annotation.Value;
|
126 |
import org.springframework.beans.factory.annotation.Value;
|
| 127 |
import org.springframework.core.io.ByteArrayResource;
|
127 |
import org.springframework.core.io.ByteArrayResource;
|
| 128 |
import org.springframework.core.io.InputStreamSource;
|
128 |
import org.springframework.core.io.InputStreamSource;
|
| 129 |
import org.springframework.data.redis.cache.RedisCacheManager;
|
- |
|
| 130 |
import org.springframework.mail.javamail.JavaMailSender;
|
129 |
import org.springframework.mail.javamail.JavaMailSender;
|
| 131 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
130 |
import org.springframework.mail.javamail.MimeMessageHelper;
|
| 132 |
import org.springframework.stereotype.Component;
|
131 |
import org.springframework.stereotype.Component;
|
| 133 |
import org.springframework.transaction.annotation.Transactional;
|
132 |
import org.springframework.transaction.annotation.Transactional;
|
| 134 |
|
133 |
|
| Line 839... |
Line 838... |
| 839 |
|
838 |
|
| 840 |
public void resetHardLimit() {
|
839 |
public void resetHardLimit() {
|
| 841 |
sdCreditService.resetHardLimit();
|
840 |
sdCreditService.resetHardLimit();
|
| 842 |
}
|
841 |
}
|
| 843 |
|
842 |
|
| - |
|
843 |
/*public void processCashDiscount() throws ProfitMandiBusinessException {
|
| - |
|
844 |
System.out.println("processing cash discount");
|
| - |
|
845 |
List<Loan> loansSettledYesterday = loanRepository.selectLoansSettledOn(LocalDate.now().minusDays(1));
|
| - |
|
846 |
loansSettledYesterday.addAll(loanRepository.selectLoansSettledOn(LocalDate.now()));
|
| - |
|
847 |
Map<Integer, List<Loan>> partnerSettledLoans = loansSettledYesterday.stream().collect(Collectors.groupingBy(x -> x.getFofoId()));
|
| - |
|
848 |
for (Entry<Integer, List<Loan>> partnerLoans : partnerSettledLoans.entrySet()) {
|
| - |
|
849 |
List<Loan> fullCdLoans = partnerLoans.getValue().stream().filter(x -> x.getInvoiceNumber() != null && x.getDays() <= ProfitMandiConstants.LOAN_PARTIAL_CREDIT_DAYS).collect(toList());
|
| - |
|
850 |
List<Loan> partialCdLoans = partnerLoans.getValue().stream().filter(x -> x.getInvoiceNumber() != null && x.getDays() > ProfitMandiConstants.LOAN_PARTIAL_CREDIT_DAYS &&
|
| - |
|
851 |
x.getDays() <= ProfitMandiConstants.LOAN_FULL_CREDIT_DAYS).collect(toList());
|
| - |
|
852 |
//List<Loan> noCdLoans = loanRepository.selectLoansDueByDays()
|
| - |
|
853 |
//
|
| - |
|
854 |
for (Loan fullCdLoan : fullCdLoans) {
|
| - |
|
855 |
LOGGER.info("FullCdLoan - {}", fullCdLoan);
|
| - |
|
856 |
schemeService.processFullCD(fullCdLoan.getInvoiceNumber());
|
| - |
|
857 |
}
|
| - |
|
858 |
|
| - |
|
859 |
for (Loan partialCdLoan : partialCdLoans) {
|
| - |
|
860 |
schemeService.processPartialCD(partialCdLoan.getInvoiceNumber());
|
| - |
|
861 |
}
|
| - |
|
862 |
|
| - |
|
863 |
*//*for (Loan noCdLoan : noCdLoans) {
|
| - |
|
864 |
schemeService.processNoCD(noCdLoan.getInvoiceNumber());
|
| - |
|
865 |
}*//*
|
| - |
|
866 |
}
|
| - |
|
867 |
|
| - |
|
868 |
}*/
|
| - |
|
869 |
|
| 844 |
private class SaleRoles {
|
870 |
private class SaleRoles {
|
| 845 |
|
871 |
|
| 846 |
private List<String> l1;
|
872 |
private List<String> l1;
|
| 847 |
private List<String> l2;
|
873 |
private List<String> l2;
|
| 848 |
|
874 |
|
| Line 1081... |
Line 1107... |
| 1081 |
}
|
1107 |
}
|
| 1082 |
}
|
1108 |
}
|
| 1083 |
|
1109 |
|
| 1084 |
|
1110 |
|
| 1085 |
public void test() throws Exception {
|
1111 |
public void test() throws Exception {
|
| - |
|
1112 |
//Utils.sendMailWithAttachments( mailSender,"amit.gupta@smartdukaan.com", null, "Hello World!", "Test Mail", null);
|
| - |
|
1113 |
//sdCreditService.updateRisk();
|
| - |
|
1114 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(175139309,
|
| - |
|
1115 |
YearMonth.of(2025, 5).atDay(1));
|
| - |
|
1116 |
System.out.println(partnerType);
|
| - |
|
1117 |
System.out.println(partnerType.nextPartnerTypes());
|
| 1086 |
this.whatsappTest();
|
1118 |
//this.whatsappTest();
|
| 1087 |
//this.reverseOppoPayout();
|
1119 |
//this.reve();
|
| 1088 |
//this.rolloutOppoPayout();
|
1120 |
//this.rolloutOppoPayout();
|
| 1089 |
//this.debitLoanAmountFromWallet();
|
1121 |
//this.debitLoanAmountFromWallet();
|
| 1090 |
//List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
|
1122 |
//List<TotalLoanAmountDueModel> totalLoanAmountDueModels = loanRepository.getDueLoansByFofoId(175139438);
|
| 1091 |
//System.out.println(totalLoanAmountDueModels);
|
1123 |
//System.out.println(totalLoanAmountDueModels);
|
| 1092 |
//runOnceTasks.findCNDiff();
|
1124 |
//runOnceTasks.findCNDiff();
|
| Line 1097... |
Line 1129... |
| 1097 |
System.out.println(getSuggestedLimit(600000d));
|
1129 |
System.out.println(getSuggestedLimit(600000d));
|
| 1098 |
System.out.println(getSuggestedLimit(700000d));
|
1130 |
System.out.println(getSuggestedLimit(700000d));
|
| 1099 |
System.out.println(getSuggestedLimit(1500000d));
|
1131 |
System.out.println(getSuggestedLimit(1500000d));
|
| 1100 |
System.out.println(getSuggestedLimit(2000000d));
|
1132 |
System.out.println(getSuggestedLimit(2000000d));
|
| 1101 |
System.out.println(getSuggestedLimit(2500000d));*/
|
1133 |
System.out.println(getSuggestedLimit(2500000d));*/
|
| - |
|
1134 |
//System.setProperty("https.protocols", "TLSv1.2");
|
| - |
|
1135 |
|
| - |
|
1136 |
|
| - |
|
1137 |
/*URL url = new URL("https://www.howsmyssl.com/a/check");
|
| - |
|
1138 |
HttpsURLConnection conn = (HttpsURLConnection) url.openConnection();
|
| - |
|
1139 |
InputStream inputStream = conn.getInputStream();
|
| - |
|
1140 |
|
| - |
|
1141 |
byte[] responseBytes = toByteArray(inputStream);
|
| - |
|
1142 |
String response = new String(responseBytes, "UTF-8");
|
| - |
|
1143 |
|
| - |
|
1144 |
System.out.println(response);
|
| - |
|
1145 |
|
| 1102 |
//Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");
|
1146 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"amit.gupta@smartdukaan.com"}, null, "DTDC AWb", "PFA");*/
|
| - |
|
1147 |
}
|
| - |
|
1148 |
|
| - |
|
1149 |
public static byte[] toByteArray(InputStream input) throws IOException {
|
| - |
|
1150 |
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
|
| - |
|
1151 |
int nRead;
|
| - |
|
1152 |
byte[] data = new byte[16384];
|
| - |
|
1153 |
while ((nRead = input.read(data, 0, data.length)) != -1) {
|
| - |
|
1154 |
buffer.write(data, 0, nRead);
|
| - |
|
1155 |
}
|
| - |
|
1156 |
return buffer.toByteArray();
|
| 1103 |
}
|
1157 |
}
|
| 1104 |
|
1158 |
|
| 1105 |
private void whatsappTest() throws Exception {
|
1159 |
private void whatsappTest() throws Exception {
|
| 1106 |
//liquidationService.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
|
1160 |
//liquidationService.processBids(ProfitMandiConstants.BID_CRON_ENUM.TODAY);
|
| 1107 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"ranu.rajput@smartdukaan.com"}, null, "Test Mail", "Mail is working");
|
1161 |
Utils.sendMailWithAttachments(googleMailSender, new String[]{"ranu.rajput@smartdukaan.com"}, null, "Test Mail", "Mail is working");
|
| Line 3422... |
Line 3476... |
| 3422 |
|
3476 |
|
| 3423 |
@Autowired
|
3477 |
@Autowired
|
| 3424 |
private SanctionRequestRepository sanctionRequestRepository;
|
3478 |
private SanctionRequestRepository sanctionRequestRepository;
|
| 3425 |
|
3479 |
|
| 3426 |
public void calculateInterestAccured() throws ProfitMandiBusinessException {
|
3480 |
public void calculateInterestAccured() throws ProfitMandiBusinessException {
|
| 3427 |
List<Loan> loans = loanRepository.selectAllActiveLoan();
|
3481 |
//List<Loan> loans = loanRepository.selectAllActiveLoan();
|
| - |
|
3482 |
List<Loan> loans = Arrays.asList(loanRepository.selectByLoanId(52669));
|
| 3428 |
|
3483 |
|
| 3429 |
for (Loan loan : loans) {
|
3484 |
for (Loan loan : loans) {
|
| 3430 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
3485 |
List<LoanStatement> loanStatements = loanStatementRepository.selectByLoanId(loan.getId());
|
| 3431 |
Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(
|
3486 |
Map<LoanReferenceType, Double> loanStatusAmount = loanStatements.stream().collect(groupingBy(
|
| 3432 |
x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> x.getAmount().doubleValue())));
|
3487 |
x -> x.getLoanReferenceType(), Collectors.summingDouble(x -> x.getAmount().doubleValue())));
|
| 3433 |
|
3488 |
|
| 3434 |
int freeDays = loan.getFreeDays();
|
3489 |
int freeDays = loan.getFreeDays();
|
| 3435 |
|
3490 |
|
| 3436 |
LocalDateTime freeDaysLimitDate = loan.getCreatedOn().plusDays(freeDays);
|
3491 |
LocalDate freeDaysLimitDate = loan.getCreatedOn().plusDays(freeDays).toLocalDate();
|
| 3437 |
|
3492 |
|
| 3438 |
LOGGER.info("freeDaysLimitDate {}", freeDaysLimitDate);
|
3493 |
LOGGER.info("Loan id - {}, freeDaysLimitDate {}", loan.getId(), freeDaysLimitDate);
|
| 3439 |
if (LocalDateTime.now().isAfter(freeDaysLimitDate)) {
|
3494 |
if (LocalDate.now().isAfter(freeDaysLimitDate)) {
|
| 3440 |
int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(), loan.getId());
|
3495 |
int loanStatementId = loanStatementRepository.selectLatestLoanSatement(loan.getFofoId(), loan.getId());
|
| 3441 |
LOGGER.info("loanStatementId {}", loanStatementId);
|
3496 |
LOGGER.info("loanStatementId {}", loanStatementId);
|
| 3442 |
if (loanStatementId != 0) {
|
3497 |
if (loanStatementId != 0) {
|
| 3443 |
this.calculateInterest(loan, loanStatusAmount, loanStatementId);
|
3498 |
this.calculateInterest(loan, loanStatusAmount, loanStatementId);
|
| 3444 |
} else {
|
3499 |
} else {
|
| 3445 |
sdCreditService.addInterest(freeDaysLimitDate.toLocalDate(), LocalDate.now(), loan, loanStatusAmount);
|
3500 |
sdCreditService.addInterest(freeDaysLimitDate, LocalDate.now(), loan, loanStatusAmount);
|
| 3446 |
}
|
3501 |
}
|
| 3447 |
}
|
3502 |
}
|
| 3448 |
|
- |
|
| 3449 |
}
|
3503 |
}
|
| 3450 |
|
- |
|
| 3451 |
|
- |
|
| 3452 |
}
|
3504 |
}
|
| 3453 |
|
3505 |
|
| 3454 |
@Autowired
|
3506 |
@Autowired
|
| 3455 |
FofoPaymentRepository fofoPaymentRepository;
|
3507 |
FofoPaymentRepository fofoPaymentRepository;
|
| 3456 |
|
3508 |
|
| Line 3473... |
Line 3525... |
| 3473 |
private void calculateInterest(Loan loan, Map<LoanReferenceType, Double> loanStatusAmount,
|
3525 |
private void calculateInterest(Loan loan, Map<LoanReferenceType, Double> loanStatusAmount,
|
| 3474 |
int loanStatementId) throws ProfitMandiBusinessException {
|
3526 |
int loanStatementId) throws ProfitMandiBusinessException {
|
| 3475 |
LoanStatement loanStatement = loanStatementRepository.selectById(loanStatementId);
|
3527 |
LoanStatement loanStatement = loanStatementRepository.selectById(loanStatementId);
|
| 3476 |
|
3528 |
|
| 3477 |
if (loanStatement.getLoanId() == loan.getId()) {
|
3529 |
if (loanStatement.getLoanId() == loan.getId()) {
|
| 3478 |
|
- |
|
| 3479 |
sdCreditService.addInterest(loanStatement.getCreatedAt().toLocalDate(), LocalDate.now(), loan, loanStatusAmount);
|
3530 |
sdCreditService.addInterest(loanStatement.getCreatedAt().toLocalDate().plusDays(1), LocalDate.now(), loan, loanStatusAmount);
|
| 3480 |
|
- |
|
| 3481 |
} else {
|
3531 |
} else {
|
| 3482 |
throw new ProfitMandiBusinessException("loanstament", loanStatement.getLoanId(), "Invalid LoanId");
|
3532 |
throw new ProfitMandiBusinessException("loanstament", loanStatement.getLoanId(), "Invalid LoanId");
|
| 3483 |
}
|
3533 |
}
|
| 3484 |
}
|
3534 |
}
|
| 3485 |
|
3535 |
|
| 3486 |
public void loanSettlement() throws Exception {
|
3536 |
public void loanSettlement() throws Exception {
|
| 3487 |
// List<Loan> blockedLoans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() >= 365).collect(toList());
|
- |
|
| 3488 |
List<Loan> loans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.getFreeDays() < 365).collect(toList());
|
3537 |
List<Loan> loans = loanRepository.selectAllActiveLoan().stream().filter(x -> x.canBeSettled()).collect(toList());
|
| 3489 |
//Settle blocked loans only when normal loans are settled
|
- |
|
| 3490 |
// loans.addAll(blockedLoans);
|
- |
|
| 3491 |
//TODO:Remove this code
|
- |
|
| 3492 |
Loan specificLoan = loanRepository.selectByLoanId(20073);
|
- |
|
| 3493 |
loans.add(0, specificLoan);
|
- |
|
| 3494 |
//TODO:Upto here
|
3538 |
//TODO:Upto here
|
| 3495 |
if (!loans.isEmpty()) {
|
3539 |
if (!loans.isEmpty()) {
|
| 3496 |
|
3540 |
|
| 3497 |
for (Loan loan : loans) {
|
3541 |
for (Loan loan : loans) {
|
| - |
|
3542 |
LOGGER.info("Loan - {}, {}", loan.getId(), loan.canBeSettled());
|
| 3498 |
double settledAmount = sdCreditService.settleLoan(loan);
|
3543 |
double settledAmount = sdCreditService.settleLoan(loan);
|
| 3499 |
|
3544 |
|
| 3500 |
List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectHoldSanctionByFofoId(loan.getFofoId());
|
3545 |
List<SanctionRequest> sanctionRequests = sanctionRequestRepository.selectHoldSanctionByFofoId(loan.getFofoId());
|
| 3501 |
for (SanctionRequest sanctionRequest : sanctionRequests) {
|
3546 |
for (SanctionRequest sanctionRequest : sanctionRequests) {
|
| 3502 |
|
3547 |
|
| Line 3920... |
Line 3965... |
| 3920 |
|
3965 |
|
| 3921 |
}
|
3966 |
}
|
| 3922 |
|
3967 |
|
| 3923 |
}
|
3968 |
}
|
| 3924 |
String messageText = this.getMessageForDueDateCross(dueDateCrossLoans);
|
3969 |
String messageText = this.getMessageForDueDateCross(dueDateCrossLoans);
|
| 3925 |
this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com", "rahul.latwal@smartdukaan.com","sdtech@smartdukaan.com"}, messageText, null, "Due Date Cross");
|
3970 |
this.sendMailOfHtmlFormat(googleMailSender, new String[]{"puneet.wahi@smartdukaan.com", "rahul.latwal@smartdukaan.com", "sdtech@smartdukaan.com"}, messageText, null, "Due Date Cross");
|
| 3926 |
|
3971 |
|
| 3927 |
|
3972 |
|
| 3928 |
if (!dueDateCrossLoans.isEmpty()) {
|
3973 |
if (!dueDateCrossLoans.isEmpty()) {
|
| 3929 |
for (Loan loan : dueDateCrossLoans) {
|
3974 |
for (Loan loan : dueDateCrossLoans) {
|
| 3930 |
|
3975 |
|