| Line 12... |
Line 12... |
| 12 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
12 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 13 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
13 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 14 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
14 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
| 15 |
import com.spice.profitmandi.dao.entity.user.Address;
|
15 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 16 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
16 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
| - |
|
17 |
import com.spice.profitmandi.dao.enumuration.transaction.LoanReferenceType;
|
| - |
|
18 |
import com.spice.profitmandi.dao.enumuration.transaction.LoanSummaryType;
|
| 17 |
import com.spice.profitmandi.dao.enumuration.transaction.SanctionStatus;
|
19 |
import com.spice.profitmandi.dao.enumuration.transaction.SanctionStatus;
|
| - |
|
20 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| 18 |
import com.spice.profitmandi.dao.model.SDCreditResponseOut;
|
21 |
import com.spice.profitmandi.dao.model.SDCreditResponseOut;
|
| 19 |
import com.spice.profitmandi.dao.model.SanctionRequestModel;
|
22 |
import com.spice.profitmandi.dao.model.SanctionRequestModel;
|
| 20 |
import com.spice.profitmandi.dao.model.SdCreditRequirementModel;
|
23 |
import com.spice.profitmandi.dao.model.SdCreditRequirementModel;
|
| 21 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
24 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
25 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| Line 29... |
Line 32... |
| 29 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
32 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
| 30 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
33 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 31 |
import com.spice.profitmandi.service.NotificationService;
|
34 |
import com.spice.profitmandi.service.NotificationService;
|
| 32 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
35 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 33 |
import com.spice.profitmandi.service.user.RetailerService;
|
36 |
import com.spice.profitmandi.service.user.RetailerService;
|
| - |
|
37 |
import com.spice.profitmandi.service.user.UserService;
|
| 34 |
import com.spice.profitmandi.web.model.LoginDetails;
|
38 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 35 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
39 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 36 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
40 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 37 |
import org.apache.logging.log4j.LogManager;
|
41 |
import org.apache.logging.log4j.LogManager;
|
| 38 |
import org.apache.logging.log4j.Logger;
|
42 |
import org.apache.logging.log4j.Logger;
|
| Line 50... |
Line 54... |
| 50 |
import java.math.BigDecimal;
|
54 |
import java.math.BigDecimal;
|
| 51 |
import java.math.RoundingMode;
|
55 |
import java.math.RoundingMode;
|
| 52 |
import java.time.Duration;
|
56 |
import java.time.Duration;
|
| 53 |
import java.time.LocalDate;
|
57 |
import java.time.LocalDate;
|
| 54 |
import java.time.LocalDateTime;
|
58 |
import java.time.LocalDateTime;
|
| - |
|
59 |
import java.time.temporal.ChronoUnit;
|
| 55 |
import java.util.*;
|
60 |
import java.util.*;
|
| 56 |
import java.util.Map.Entry;
|
61 |
import java.util.Map.Entry;
|
| 57 |
import java.util.stream.Collectors;
|
62 |
import java.util.stream.Collectors;
|
| 58 |
|
63 |
|
| 59 |
@Controller
|
64 |
@Controller
|
| 60 |
@Transactional(rollbackOn = Throwable.class)
|
65 |
@Transactional(rollbackOn = Throwable.class)
|
| 61 |
public class SDCreditController {
|
66 |
public class SDCreditController {
|
| 62 |
|
67 |
|
| 63 |
@Autowired
|
68 |
@Autowired
|
| 64 |
private RetailerService retailerService;
|
69 |
private RetailerService retailerService;
|
| - |
|
70 |
@Autowired
|
| - |
|
71 |
private UserService userService;
|
| 65 |
|
72 |
|
| 66 |
@Autowired
|
73 |
@Autowired
|
| 67 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
74 |
SDCreditRequirementRepository sdCreditRequirementRepository;
|
| 68 |
|
75 |
|
| 69 |
@Autowired
|
76 |
@Autowired
|
| Line 401... |
Line 408... |
| 401 |
model.addAttribute("loanCountMap", loanCountMap);
|
408 |
model.addAttribute("loanCountMap", loanCountMap);
|
| 402 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
409 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 403 |
return "loan-summary";
|
410 |
return "loan-summary";
|
| 404 |
|
411 |
|
| 405 |
}
|
412 |
}
|
| - |
|
413 |
@RequestMapping(value = "/getPartnerWiseLoanSummary", method = RequestMethod.GET)
|
| - |
|
414 |
public String getPartnerWiseLoanSummary(HttpServletRequest request, @RequestParam LoanSummaryType loanSummaryType, Model model) throws ProfitMandiBusinessException {
|
| - |
|
415 |
Map<Integer, FofoReportingModel> fofoReportingModelMap = csService.getPartnerIdSalesHeaders();
|
| - |
|
416 |
List<Loan> loans = new ArrayList<>();
|
| - |
|
417 |
List<Loan> activeLoans = loanRepository.selectAllActiveLoan();
|
| - |
|
418 |
if (loanSummaryType.equals(LoanSummaryType.TOTAL_LOAN)) {
|
| - |
|
419 |
loans.addAll(activeLoans);
|
| - |
|
420 |
} else if (loanSummaryType.equals(LoanSummaryType.DEFAULT_LOAN)) {
|
| - |
|
421 |
for (Loan loan : activeLoans) {
|
| - |
|
422 |
long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDateTime.now());
|
| - |
|
423 |
if (noOfdaysBetween > 15) {
|
| - |
|
424 |
loans.add(loan);
|
| - |
|
425 |
}
|
| - |
|
426 |
}
|
| - |
|
427 |
|
| - |
|
428 |
} else if (loanSummaryType.equals(LoanSummaryType.DUE_LOAN)) {
|
| - |
|
429 |
for (Loan loan : activeLoans) {
|
| - |
|
430 |
long noOfdaysBetween = ChronoUnit.DAYS.between(loan.getDueDate().toLocalDate(), LocalDateTime.now());
|
| - |
|
431 |
if (noOfdaysBetween <= 15 && noOfdaysBetween >= 0) {
|
| - |
|
432 |
loans.add(loan);
|
| - |
|
433 |
}
|
| - |
|
434 |
}
|
| - |
|
435 |
}
|
| - |
|
436 |
List<Integer> fofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| - |
|
437 |
Map<Integer, Double> fofoIdLoansMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(),Collectors.summingDouble(x->x.getPendingAmount().doubleValue())));
|
| - |
|
438 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
| - |
|
439 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| - |
|
440 |
model.addAttribute("loans", loans);
|
| - |
|
441 |
model.addAttribute("fofoReportingModelMap", fofoReportingModelMap);
|
| - |
|
442 |
model.addAttribute("fofoIdLoansMap", fofoIdLoansMap);
|
| - |
|
443 |
return "partner-wise-loan-summary";
|
| - |
|
444 |
}
|
| 406 |
|
445 |
|
| 407 |
@RequestMapping(value = "/getLoanSummary", method = RequestMethod.GET)
|
446 |
@RequestMapping(value = "/getLoanSummary", method = RequestMethod.GET)
|
| 408 |
public String getLoanSummary(HttpServletRequest request, @RequestParam int fofoId, Model model) throws ProfitMandiBusinessException {
|
447 |
public String getLoanSummary(HttpServletRequest request, @RequestParam int fofoId, Model model) throws ProfitMandiBusinessException {
|
| 409 |
|
448 |
|
| 410 |
SDCreditResponseOut sdCreditResponseOut = sdCreditService.sdDirectService(fofoId);
|
449 |
SDCreditResponseOut sdCreditResponseOut = sdCreditService.sdDirectService(fofoId);
|