| Line 452... |
Line 452... |
| 452 |
|
452 |
|
| 453 |
/*Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailersInternalFalse();
|
453 |
/*Map<Integer, CustomRetailer> customRetailers = retailerService.getAllFofoRetailersInternalFalse();
|
| 454 |
|
454 |
|
| 455 |
List<Integer> retailerIds = customRetailers.values().stream().map(CustomRetailer::getPartnerId).collect(Collectors.toList());*/
|
455 |
List<Integer> retailerIds = customRetailers.values().stream().map(CustomRetailer::getPartnerId).collect(Collectors.toList());*/
|
| 456 |
|
456 |
|
| 457 |
List<Integer> retailerIds = Arrays.asList(175139615,175139391,175135707,175139854,175139302,175139710,175139749);
|
457 |
List<Integer> retailerIds = Arrays.asList(175139178,175139391,175139651,175139287,175139507,175139314,175139311,175139302,175139273,175138814,175138867,175138541,175139583,175139218,175139308,175139615,175139266,175139247,175139158,175139253);
|
| 458 |
Map<Integer,CustomRetailer> customRetailers = retailerService.getFofoRetailers(retailerIds);
|
458 |
Map<Integer,CustomRetailer> customRetailers = retailerService.getFofoRetailers(retailerIds);
|
| 459 |
|
459 |
|
| 460 |
//partner daily investment
|
460 |
//partner daily investment
|
| 461 |
List<Loan> defaultLoans = sdCreditService.getDefaultLoans();
|
461 |
List<Loan> defaultLoans = sdCreditService.getDefaultLoans();
|
| 462 |
Map<Integer,List<Loan>> defaultLoanMap = defaultLoans.stream().collect(Collectors.groupingBy(Loan::getFofoId));
|
462 |
Map<Integer,List<Loan>> defaultLoanMap = defaultLoans.stream().collect(Collectors.groupingBy(Loan::getFofoId));
|
| Line 479... |
Line 479... |
| 479 |
Map<Integer, Long> currentMonthPartnerReturnOrderInfoModelMap = currentMonthReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
|
479 |
Map<Integer, Long> currentMonthPartnerReturnOrderInfoModelMap = currentMonthReturnOrderInfoModels.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getRefundAmount()))));
|
| 480 |
|
480 |
|
| 481 |
List<Order> currentMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(currentMonthStartDate, currentMonthEndDate, OrderStatus.RTO_REFUNDED);
|
481 |
List<Order> currentMonthRtoRefundOrders = orderRepository.selectAllOrderDatesBetweenByStatus(currentMonthStartDate, currentMonthEndDate, OrderStatus.RTO_REFUNDED);
|
| 482 |
Map<Integer, Long> currentMonthRtoRefundOrderMap = currentMonthRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
|
482 |
Map<Integer, Long> currentMonthRtoRefundOrderMap = currentMonthRtoRefundOrders.stream().collect(Collectors.groupingBy(x -> x.getRetailerId(), Collectors.summingLong(x -> Math.round(x.getTotalAmount()))));
|
| 483 |
|
483 |
|
| 484 |
|
- |
|
| 485 |
// last month return data
|
484 |
// last month return data
|
| 486 |
YearMonth lastMonth = YearMonth.now().minusMonths(1);
|
485 |
YearMonth lastMonth = YearMonth.now().minusMonths(1);
|
| 487 |
String lastMonthStringValue = String.valueOf(lastMonth);
|
486 |
String lastMonthStringValue = String.valueOf(lastMonth);
|
| 488 |
LocalDateTime lastMontStartDate = lastMonth.atDay(1).atStartOfDay();
|
487 |
LocalDateTime lastMontStartDate = lastMonth.atDay(1).atStartOfDay();
|
| 489 |
LocalDateTime lastMonthEndDate = lastMonth.atEndOfMonth().atTime(23, 59, 59);
|
488 |
LocalDateTime lastMonthEndDate = lastMonth.atEndOfMonth().atTime(23, 59, 59);
|
| Line 713... |
Line 712... |
| 713 |
|
712 |
|
| 714 |
double totalMtdTertiaryAmount = brandMtdTertiaryAmount.values().stream().mapToDouble(Double::doubleValue).sum();
|
713 |
double totalMtdTertiaryAmount = brandMtdTertiaryAmount.values().stream().mapToDouble(Double::doubleValue).sum();
|
| 715 |
|
714 |
|
| 716 |
fofoTotalMtdTertiaryMap.put(fofoId,totalMtdTertiaryAmount);
|
715 |
fofoTotalMtdTertiaryMap.put(fofoId,totalMtdTertiaryAmount);
|
| 717 |
|
716 |
|
| 718 |
LOGGER.info("fofoTotalMtdTertiaryMap- {}",fofoTotalMtdTertiaryMap);
|
- |
|
| 719 |
LOGGER.info("fofoBrandMtdTertiaryMap- {}",fofoBrandMtdTertiaryMap);
|
717 |
LOGGER.info("fofoBrandMtdTertiaryMap- {}",fofoBrandMtdTertiaryMap);
|
| 720 |
|
718 |
|
| 721 |
|
719 |
|
| 722 |
List<BrandWiseModel> brandWiseMtdSecondary = orderRepository.selectAllBilledByCategoryOrderGroupByBrandFofoId(fofoId, currentMonthStartDate,Arrays.asList(10006,10009,10010));
|
720 |
List<BrandWiseModel> brandWiseMtdSecondary = orderRepository.selectAllBilledByCategoryOrderGroupByBrandFofoId(fofoId, currentMonthStartDate,Arrays.asList(10006,10009,10010));
|
| 723 |
Map<String,Long> brandWiseMtdSecondaryMap = brandWiseMtdSecondary.stream().collect(Collectors.toMap(BrandWiseModel::getBrand,BrandWiseModel::getAmount));
|
721 |
Map<String,Long> brandWiseMtdSecondaryMap = brandWiseMtdSecondary.stream().collect(Collectors.toMap(BrandWiseModel::getBrand,BrandWiseModel::getAmount));
|
| 724 |
fofoBrandWiseMtdSecondaryMap.put(fofoId,brandWiseMtdSecondaryMap);
|
- |
|
| 725 |
|
722 |
|
| - |
|
723 |
//retrunInfo
|
| - |
|
724 |
List<BrandWiseReturnInfo> brandWiseReturnInfos = returnOrderInfoRepository.selectAllBrandWiseByBetweenDate(currentMonthStartDate,currentMonthEndDate.plusDays(1),fofoId);
|
| - |
|
725 |
Map<String,Double> brandWiseReturnInfoMap = brandWiseReturnInfos.stream().collect(Collectors.toMap(BrandWiseReturnInfo::getBrand, x->x.getReturnAmount()));
|
| - |
|
726 |
|
| - |
|
727 |
LOGGER.info("brandWiseReturnInfos {}",brandWiseReturnInfos);
|
| - |
|
728 |
LOGGER.info("brandWiseReturnInfoMap {}",brandWiseReturnInfoMap);
|
| - |
|
729 |
//Rto retrunInfo
|
| - |
|
730 |
List<BrandWiseReturnInfo> brandWiseRTOReturnInfos = returnOrderInfoRepository.selectAllBrandWiseRTORefundByBetweenDate(currentMonthStartDate,currentMonthEndDate.plusDays(1),fofoId);
|
| - |
|
731 |
Map<String,Double> brandWiseRTOReturnInfoMap = brandWiseRTOReturnInfos.stream().collect(Collectors.toMap(BrandWiseReturnInfo::getBrand, x->x.getReturnAmount()));
|
| - |
|
732 |
|
| - |
|
733 |
// Step 1: Get union of all brand keys
|
| - |
|
734 |
Set<String> allBrands = new HashSet<>();
|
| - |
|
735 |
allBrands.addAll(brandWiseMtdSecondaryMap.keySet());
|
| - |
|
736 |
allBrands.addAll(brandWiseReturnInfoMap.keySet());
|
| - |
|
737 |
allBrands.addAll(brandWiseRTOReturnInfoMap.keySet());
|
| - |
|
738 |
|
| - |
|
739 |
// Step 2: Calculate net secondary for each brand
|
| - |
|
740 |
Map<String, Long> brandWiseMtdNetSecondaryMap = new HashMap<>();
|
| - |
|
741 |
|
| - |
|
742 |
for (String brand : allBrands) {
|
| - |
|
743 |
Long billedAmount = brandWiseMtdSecondaryMap.getOrDefault(brand, 0L);
|
| - |
|
744 |
Double returnAmount = brandWiseReturnInfoMap.getOrDefault(brand, 0d);
|
| - |
|
745 |
Double rtoReturnAmount = brandWiseRTOReturnInfoMap.getOrDefault(brand, 0d);
|
| - |
|
746 |
|
| - |
|
747 |
double netSecondary = billedAmount - (returnAmount + rtoReturnAmount);
|
| - |
|
748 |
brandWiseMtdNetSecondaryMap.put(brand, (long) Math.round(netSecondary));
|
| - |
|
749 |
}
|
| - |
|
750 |
|
| - |
|
751 |
|
| - |
|
752 |
LOGGER.info("brandWiseMtdNetSecondaryMap {}",brandWiseMtdNetSecondaryMap );
|
| - |
|
753 |
|
| - |
|
754 |
|
| - |
|
755 |
fofoBrandWiseMtdSecondaryMap.put(fofoId,brandWiseMtdNetSecondaryMap);
|
| - |
|
756 |
|
| 726 |
long mtdTotalSecondary = brandWiseMtdSecondary.stream().mapToLong(x -> x.getAmount() != 0 ? x.getAmount() : 0L).sum();
|
757 |
long mtdTotalSecondary = brandWiseMtdNetSecondaryMap.values().stream().mapToLong(Long::longValue).sum();
|
| 727 |
|
758 |
|
| 728 |
fofoTotalMtdSecondaryMap.put(fofoId,mtdTotalSecondary);
|
759 |
fofoTotalMtdSecondaryMap.put(fofoId,mtdTotalSecondary);
|
| 729 |
|
760 |
|
| 730 |
// generate investment info
|
761 |
// generate investment info
|
| 731 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
762 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| Line 952... |
Line 983... |
| 952 |
if(fofoInvestmentModelValue != null){
|
983 |
if(fofoInvestmentModelValue != null){
|
| 953 |
row.addAll(Arrays.asList(
|
984 |
row.addAll(Arrays.asList(
|
| 954 |
fofoInvestmentModelValue.getCounterPotential(),
|
985 |
fofoInvestmentModelValue.getCounterPotential(),
|
| 955 |
fofoInvestmentModelValue.getShortInvestment(),
|
986 |
fofoInvestmentModelValue.getShortInvestment(),
|
| 956 |
fofoInvestmentModelValue.getDefaultLoan(),
|
987 |
fofoInvestmentModelValue.getDefaultLoan(),
|
| 957 |
fofoInvestmentModelValue.getInvestmentLevel(),
|
988 |
fofoInvestmentModelValue.getInvestmentLevel() +"%",
|
| 958 |
"-"+fofoInvestmentModelValue.getActiveLoan(),
|
989 |
"-"+fofoInvestmentModelValue.getActiveLoan(),
|
| 959 |
fofoInvestmentModelValue.getPoValue(),
|
990 |
fofoInvestmentModelValue.getPoValue(),
|
| 960 |
fofoInvestmentModelValue.getAgreedInvestment(),
|
991 |
fofoInvestmentModelValue.getAgreedInvestment(),
|
| 961 |
fofoInvestmentModelValue.getWallet(),
|
992 |
fofoInvestmentModelValue.getWallet(),
|
| 962 |
fofoInvestmentModelValue.getPoAndBilled(),
|
993 |
fofoInvestmentModelValue.getPoAndBilled(),
|