| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| - |
|
3 |
import java.math.BigDecimal;
|
| - |
|
4 |
import java.math.RoundingMode;
|
| - |
|
5 |
import java.time.Duration;
|
| - |
|
6 |
import java.time.LocalDate;
|
| - |
|
7 |
import java.time.LocalDateTime;
|
| - |
|
8 |
import java.time.LocalTime;
|
| - |
|
9 |
import java.time.temporal.ChronoUnit;
|
| - |
|
10 |
import java.util.ArrayList;
|
| - |
|
11 |
import java.util.Arrays;
|
| - |
|
12 |
import java.util.HashMap;
|
| - |
|
13 |
import java.util.HashSet;
|
| - |
|
14 |
import java.util.List;
|
| - |
|
15 |
import java.util.Map;
|
| - |
|
16 |
import java.util.Map.Entry;
|
| - |
|
17 |
import java.util.Set;
|
| - |
|
18 |
import java.util.stream.Collectors;
|
| - |
|
19 |
|
| - |
|
20 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
21 |
import javax.transaction.Transactional;
|
| - |
|
22 |
|
| - |
|
23 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
24 |
import org.apache.logging.log4j.Logger;
|
| - |
|
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
26 |
import org.springframework.mail.javamail.JavaMailSender;
|
| - |
|
27 |
import org.springframework.stereotype.Controller;
|
| - |
|
28 |
import org.springframework.ui.Model;
|
| - |
|
29 |
import org.springframework.web.bind.annotation.RequestBody;
|
| - |
|
30 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
31 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
32 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
33 |
|
| 3 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
34 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 4 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
35 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 5 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
36 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 6 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
37 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 7 |
import com.spice.profitmandi.common.util.Utils;
|
38 |
import com.spice.profitmandi.common.util.Utils;
|
| Line 9... |
Line 40... |
| 9 |
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
|
40 |
import com.spice.profitmandi.dao.entity.dtr.CreditAccount;
|
| 10 |
import com.spice.profitmandi.dao.entity.dtr.CreditStatus;
|
41 |
import com.spice.profitmandi.dao.entity.dtr.CreditStatus;
|
| 11 |
import com.spice.profitmandi.dao.entity.fofo.CurrentPartnerDailyInvestment;
|
42 |
import com.spice.profitmandi.dao.entity.fofo.CurrentPartnerDailyInvestment;
|
| 12 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 13 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 14 |
import com.spice.profitmandi.dao.entity.transaction.*;
|
45 |
import com.spice.profitmandi.dao.entity.transaction.Loan;
|
| - |
|
46 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
47 |
import com.spice.profitmandi.dao.entity.transaction.SDCreditRequirement;
|
| - |
|
48 |
import com.spice.profitmandi.dao.entity.transaction.SanctionRequest;
|
| - |
|
49 |
import com.spice.profitmandi.dao.entity.transaction.UserWallet;
|
| 15 |
import com.spice.profitmandi.dao.entity.user.Address;
|
50 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 16 |
import com.spice.profitmandi.dao.enumuration.fofo.Gateway;
|
51 |
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;
|
52 |
import com.spice.profitmandi.dao.enumuration.transaction.LoanSummaryType;
|
| 19 |
import com.spice.profitmandi.dao.enumuration.transaction.SanctionStatus;
|
53 |
import com.spice.profitmandi.dao.enumuration.transaction.SanctionStatus;
|
| 20 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
54 |
import com.spice.profitmandi.dao.model.FofoReportingModel;
|
| 21 |
import com.spice.profitmandi.dao.model.SDCreditResponseOut;
|
55 |
import com.spice.profitmandi.dao.model.SDCreditResponseOut;
|
| 22 |
import com.spice.profitmandi.dao.model.SanctionRequestModel;
|
56 |
import com.spice.profitmandi.dao.model.SanctionRequestModel;
|
| Line 26... |
Line 60... |
| 26 |
import com.spice.profitmandi.dao.repository.cs.CsService1;
|
60 |
import com.spice.profitmandi.dao.repository.cs.CsService1;
|
| 27 |
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
|
61 |
import com.spice.profitmandi.dao.repository.dtr.CreditAccountRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
62 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
63 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.fofo.CurrentPartnerDailyInvestmentRepository;
|
64 |
import com.spice.profitmandi.dao.repository.fofo.CurrentPartnerDailyInvestmentRepository;
|
| - |
|
65 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
66 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 32 |
import com.spice.profitmandi.dao.repository.transaction.*;
|
67 |
import com.spice.profitmandi.dao.repository.transaction.LoanRepository;
|
| - |
|
68 |
import com.spice.profitmandi.dao.repository.transaction.LoanStatementRepository;
|
| - |
|
69 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| - |
|
70 |
import com.spice.profitmandi.dao.repository.transaction.SDCreditRequirementRepository;
|
| - |
|
71 |
import com.spice.profitmandi.dao.repository.transaction.SanctionRequestRepository;
|
| - |
|
72 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 33 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
73 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| 34 |
import com.spice.profitmandi.service.NotificationService;
|
74 |
import com.spice.profitmandi.service.NotificationService;
|
| 35 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
75 |
import com.spice.profitmandi.service.transaction.SDCreditService;
|
| 36 |
import com.spice.profitmandi.service.user.RetailerService;
|
76 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 37 |
import com.spice.profitmandi.service.user.UserService;
|
77 |
import com.spice.profitmandi.service.user.UserService;
|
| 38 |
import com.spice.profitmandi.web.model.LoginDetails;
|
78 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 39 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
79 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 40 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
80 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 41 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 42 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 43 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 44 |
import org.springframework.mail.javamail.JavaMailSender;
|
- |
|
| 45 |
import org.springframework.stereotype.Controller;
|
- |
|
| 46 |
import org.springframework.ui.Model;
|
- |
|
| 47 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 48 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 49 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 50 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 51 |
|
- |
|
| 52 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 53 |
import javax.transaction.Transactional;
|
- |
|
| 54 |
import java.math.BigDecimal;
|
- |
|
| 55 |
import java.math.RoundingMode;
|
- |
|
| 56 |
import java.time.Duration;
|
- |
|
| 57 |
import java.time.LocalDate;
|
- |
|
| 58 |
import java.time.LocalDateTime;
|
- |
|
| 59 |
import java.time.temporal.ChronoUnit;
|
- |
|
| 60 |
import java.util.*;
|
- |
|
| 61 |
import java.util.Map.Entry;
|
- |
|
| 62 |
import java.util.stream.Collectors;
|
- |
|
| 63 |
|
81 |
|
| 64 |
@Controller
|
82 |
@Controller
|
| 65 |
@Transactional(rollbackOn = Throwable.class)
|
83 |
@Transactional(rollbackOn = Throwable.class)
|
| 66 |
public class SDCreditController {
|
84 |
public class SDCreditController {
|
| 67 |
|
85 |
|
| Line 132... |
Line 150... |
| 132 |
private JavaMailSender mailSender;
|
150 |
private JavaMailSender mailSender;
|
| 133 |
|
151 |
|
| 134 |
@Autowired
|
152 |
@Autowired
|
| 135 |
private MVCResponseSender mvcResponseSender;
|
153 |
private MVCResponseSender mvcResponseSender;
|
| 136 |
|
154 |
|
| - |
|
155 |
@Autowired
|
| - |
|
156 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
| - |
|
157 |
|
| 137 |
private static final Logger LOGGER = LogManager.getLogger(SDCreditController.class);
|
158 |
private static final Logger LOGGER = LogManager.getLogger(SDCreditController.class);
|
| 138 |
|
159 |
|
| 139 |
@RequestMapping(value = "/getSDCreditReq", method = RequestMethod.GET)
|
160 |
@RequestMapping(value = "/getSDCreditReq", method = RequestMethod.GET)
|
| 140 |
public String getSDCreditReq(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
161 |
public String getSDCreditReq(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 141 |
|
162 |
|
| Line 252... |
Line 273... |
| 252 |
|
273 |
|
| 253 |
Map<Integer, Long> partnerCreditDaysMap = new HashMap<>();
|
274 |
Map<Integer, Long> partnerCreditDaysMap = new HashMap<>();
|
| 254 |
|
275 |
|
| 255 |
Map<Integer, Integer> partnerActiveLoanMap = new HashMap<>();
|
276 |
Map<Integer, Integer> partnerActiveLoanMap = new HashMap<>();
|
| 256 |
|
277 |
|
| - |
|
278 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
279 |
|
| - |
|
280 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| - |
|
281 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), 0, false);
|
| - |
|
282 |
|
| - |
|
283 |
Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), 0, false);
|
| - |
|
284 |
|
| - |
|
285 |
Map<Integer, Double> lmsSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| - |
|
286 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), 0, false);
|
| - |
|
287 |
|
| - |
|
288 |
|
| 257 |
for (Integer fofoId : fofoIds) {
|
289 |
for (Integer fofoId : fofoIds) {
|
| 258 |
List<Loan> loans = loanRepository.selectActiveLoan(fofoId);
|
290 |
List<Loan> loans = loanRepository.selectActiveLoan(fofoId);
|
| 259 |
|
291 |
|
| - |
|
292 |
|
| 260 |
if (!loans.isEmpty()) {
|
293 |
if (!loans.isEmpty()) {
|
| 261 |
|
294 |
|
| 262 |
partnerActiveLoanMap.put(fofoId, loans.size());
|
295 |
partnerActiveLoanMap.put(fofoId, loans.size());
|
| 263 |
Loan loan = loans.get(loans.size() - 1);
|
296 |
Loan loan = loans.get(loans.size() - 1);
|
| 264 |
|
297 |
|
| Line 284... |
Line 317... |
| 284 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
317 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| 285 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
318 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| 286 |
|
319 |
|
| 287 |
model.addAttribute("userWalletMap", userWalletMap);
|
320 |
model.addAttribute("userWalletMap", userWalletMap);
|
| 288 |
model.addAttribute("authMap", authMap);
|
321 |
model.addAttribute("authMap", authMap);
|
| 289 |
|
- |
|
| - |
|
322 |
model.addAttribute("lmtdSale", lmtdSale);
|
| - |
|
323 |
model.addAttribute("mtdSale", mtdSale);
|
| - |
|
324 |
model.addAttribute("lmsSale", lmsSale);
|
| 290 |
|
325 |
|
| 291 |
}
|
326 |
}
|
| 292 |
|
327 |
|
| 293 |
model.addAttribute("sanctionRequests", sanctionRequests);
|
328 |
model.addAttribute("sanctionRequests", sanctionRequests);
|
| 294 |
|
329 |
|
| Line 353... |
Line 388... |
| 353 |
|
388 |
|
| 354 |
|
389 |
|
| 355 |
sanctionRequest.setApprovalAmount(sanctionRequestModel.getApprovalAmount());
|
390 |
sanctionRequest.setApprovalAmount(sanctionRequestModel.getApprovalAmount());
|
| 356 |
sanctionRequest.setStatus(sanctionRequestModel.getStatus());
|
391 |
sanctionRequest.setStatus(sanctionRequestModel.getStatus());
|
| 357 |
sanctionRequest.setStockHold(sanctionRequestModel.isStockHold());
|
392 |
sanctionRequest.setStockHold(sanctionRequestModel.isStockHold());
|
| - |
|
393 |
|
| - |
|
394 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| - |
|
395 |
|
| - |
|
396 |
Map<Integer, Double> lmtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| - |
|
397 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.with(LocalTime.MAX).minusMonths(1), sanctionRequest.getFofoId(), false);
|
| - |
|
398 |
|
| - |
|
399 |
Map<Integer, Double> mtdSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX), sanctionRequest.getFofoId(), false);
|
| - |
|
400 |
|
| - |
|
401 |
Map<Integer, Double> lmsSale = fofoOrderItemRepository.selectSumMopGroupByRetailer(
|
| - |
|
402 |
curDate.withDayOfMonth(1).minusMonths(1), curDate.withDayOfMonth(1), sanctionRequest.getFofoId(), false);
|
| - |
|
403 |
|
| - |
|
404 |
|
| 358 |
|
405 |
|
| 359 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = partnerDailyInvestmentRepository.selectAll(fofoIds, LocalDate.now().minusDays(1)).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
406 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = partnerDailyInvestmentRepository.selectAll(fofoIds, LocalDate.now().minusDays(1)).stream().collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 360 |
|
407 |
|
| 361 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(new HashSet<>(fofoIds)).stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
408 |
Map<Integer, UserWallet> userWalletMap = userWalletRepository.selectByRetailerIds(new HashSet<>(fofoIds)).stream().collect(Collectors.toMap(x -> x.getUserId(), x -> x));
|
| 362 |
|
409 |
|
| Line 366... |
Line 413... |
| 366 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
413 |
model.addAttribute("partnerDailyInvestmentMap", partnerDailyInvestmentMap);
|
| 367 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
414 |
model.addAttribute("sdCreditRequirementMap", sdCreditRequirementMap);
|
| 368 |
model.addAttribute("userWalletMap", userWalletMap);
|
415 |
model.addAttribute("userWalletMap", userWalletMap);
|
| 369 |
|
416 |
|
| 370 |
model.addAttribute("sanctionStatus", SanctionStatus.values());
|
417 |
model.addAttribute("sanctionStatus", SanctionStatus.values());
|
| - |
|
418 |
|
| - |
|
419 |
model.addAttribute("lmtdSale", lmtdSale);
|
| - |
|
420 |
model.addAttribute("mtdSale", mtdSale);
|
| - |
|
421 |
model.addAttribute("lmsSale", lmsSale);
|
| - |
|
422 |
|
| 371 |
|
423 |
|
| 372 |
return "sanction-request-row";
|
424 |
return "sanction-request-row";
|
| 373 |
|
425 |
|
| 374 |
}
|
426 |
}
|
| 375 |
|
427 |
|
| Line 437... |
Line 489... |
| 437 |
}
|
489 |
}
|
| 438 |
}
|
490 |
}
|
| 439 |
List<Integer> fofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
491 |
List<Integer> fofoIds = loans.stream().map(x -> x.getFofoId()).collect(Collectors.toList());
|
| 440 |
Map<Integer, Double> fofoIdLoansMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> x.getPendingAmount().doubleValue())));
|
492 |
Map<Integer, Double> fofoIdLoansMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.summingDouble(x -> x.getPendingAmount().doubleValue())));
|
| 441 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
493 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(fofoIds);
|
| 442 |
Map<Integer, Long> loanCountMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
494 |
Map<Integer, Long> loanCountMap = loans.stream().collect(Collectors.groupingBy(x -> x.getFofoId(), Collectors.counting()));
|
| 443 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
495 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 444 |
model.addAttribute("loans", loans);
|
496 |
model.addAttribute("loans", loans);
|
| 445 |
model.addAttribute("fofoReportingModelMap", fofoReportingModelMap);
|
497 |
model.addAttribute("fofoReportingModelMap", fofoReportingModelMap);
|
| 446 |
model.addAttribute("fofoIdLoansMap", fofoIdLoansMap);
|
498 |
model.addAttribute("fofoIdLoansMap", fofoIdLoansMap);
|
| 447 |
model.addAttribute("loanCountMap", loanCountMap);
|
499 |
model.addAttribute("loanCountMap", loanCountMap);
|