| Line 622... |
Line 622... |
| 622 |
public ResponseEntity<?> getPartnerTarget(HttpServletRequest request,
|
622 |
public ResponseEntity<?> getPartnerTarget(HttpServletRequest request,
|
| 623 |
@RequestParam(name = "gmailId") String gmailId, @RequestParam String dayValue)
|
623 |
@RequestParam(name = "gmailId") String gmailId, @RequestParam String dayValue)
|
| 624 |
throws ProfitMandiBusinessException {
|
624 |
throws ProfitMandiBusinessException {
|
| 625 |
|
625 |
|
| 626 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
626 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 627 |
|
- |
|
| 628 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
627 |
Map<String, Set<Integer>> storeGuyMap = csService.getAuthUserPartnerIdMapping();
|
| 629 |
|
- |
|
| 630 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
628 |
Set<Integer> fofoIds = storeGuyMap.get(authUser.getEmailId());
|
| 631 |
|
- |
|
| 632 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Itel", "Almost New", "Others");
|
629 |
List<String> brands = Arrays.asList("Vivo", "Samsung", "Oppo", "Itel", "Almost New", "Others");
|
| 633 |
|
630 |
|
| 634 |
float totalPartnerTargetSecondary = 0;
|
631 |
float totalPartnerTargetSecondary = 0;
|
| 635 |
float totalPartnerTargetCollection = 0;
|
632 |
float totalPartnerTargetCollection = 0;
|
| 636 |
float totalPartnerAchievementSecondary = 0;
|
633 |
float totalPartnerAchievementSecondary = 0;
|
| 637 |
float totalPartnerAchievementCollection = 0;
|
634 |
float totalPartnerAchievementCollection = 0;
|
| 638 |
TargetModel tm = new TargetModel();
|
635 |
TargetModel tm = new TargetModel();
|
| 639 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
636 |
Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
|
| 640 |
|
- |
|
| 641 |
Map<Integer, Long> partnerTicketCount = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
637 |
Map<Integer, Long> partnerTicketCount = ticketRepository.selectAllOpenTicketsGroupByRetailer();
|
| 642 |
|
638 |
|
| 643 |
LOGGER.info("partnerTicketCount {}", partnerTicketCount);
|
639 |
LOGGER.info("partnerTicketCount {}", partnerTicketCount);
|
| 644 |
|
640 |
|
| 645 |
List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
|
641 |
List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
|
| Line 656... |
Line 652... |
| 656 |
|
652 |
|
| 657 |
}
|
653 |
}
|
| 658 |
|
654 |
|
| 659 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
655 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| 660 |
.selectAll(fofoIdList, startDate.toLocalDate().minusDays(1));
|
656 |
.selectAll(fofoIdList, startDate.toLocalDate().minusDays(1));
|
| - |
|
657 |
|
| 661 |
if (!partnerDailyInvestments.isEmpty()) {
|
658 |
if (!partnerDailyInvestments.isEmpty()) {
|
| 662 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
659 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
| 663 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
660 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 664 |
}
|
661 |
}
|
| 665 |
|
662 |
|
| Line 667... |
Line 664... |
| 667 |
|
664 |
|
| 668 |
Map<Integer, CustomRetailer> customRetailers = fofoIdList.stream().map(x -> customRetailerMap.get(x))
|
665 |
Map<Integer, CustomRetailer> customRetailers = fofoIdList.stream().map(x -> customRetailerMap.get(x))
|
| 669 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
666 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
| 670 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
667 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 671 |
|
668 |
|
| 672 |
/*
|
- |
|
| 673 |
* Map<Integer, PartnerCollectionPlanModel> collectionPlans =
|
- |
|
| 674 |
* userWalletRepository .getPartnerWiseTargetCollections(fofoIdList,
|
- |
|
| 675 |
* startDate).stream() .collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
- |
|
| 676 |
*/
|
- |
|
| 677 |
|
- |
|
| 678 |
Map<Integer, PartnerCollectionAchievementModel> collectionAchievementMap = userWalletRepository
|
669 |
Map<Integer, PartnerCollectionAchievementModel> collectionAchievementMap = userWalletRepository
|
| 679 |
.getPartnerWiseCollectionAchievement(fofoIdList, startDate).stream()
|
670 |
.getPartnerWiseCollectionAchievement(fofoIdList, startDate).stream()
|
| 680 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
671 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 681 |
|
672 |
|
| - |
|
673 |
List<Integer> remarkIds = partnerCollectionRemarkRepository.selectMaxRemarkId(fofoIdList);
|
| - |
|
674 |
|
| - |
|
675 |
LOGGER.info("remarkIds {}", remarkIds);
|
| - |
|
676 |
|
| - |
|
677 |
long todayCollectionCount = 0;
|
| - |
|
678 |
if (!remarkIds.isEmpty()) {
|
| 682 |
Map<Integer, PartnerCollectionPlan> todayTarget = partnerCollectionPlanRepository
|
679 |
todayCollectionCount = partnerCollectionRemarkRepository
|
| 683 |
.selectByLocalDateAndFofoIds(startDate.toLocalDate(), fofoIdList, true).stream()
|
680 |
.selectByAuthIdAndIds(authUser.getId(), remarkIds).stream()
|
| - |
|
681 |
.filter(x -> x.getCreateTimestamp().toLocalDate().equals(LocalDate.now()))
|
| 684 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
682 |
.collect(Collectors.counting());
|
| - |
|
683 |
|
| - |
|
684 |
}
|
| 685 |
|
685 |
|
| 686 |
int todayCollectionCount = todayTarget.size();
|
- |
|
| 687 |
Map<Integer, PartnerCollectionPlanModel> foundCollectionMap = partnerCollectionService
|
686 |
Map<Integer, PartnerCollectionPlanModel> foundCollectionMap = partnerCollectionService
|
| 688 |
.getCollectionMap(fofoIdList, startDate);
|
687 |
.getCollectionMap(fofoIdList, startDate);
|
| 689 |
|
688 |
|
| 690 |
Map<Integer, List<PartnerSecondaryPlanModel>> partnerSecondayPlans = orderRepository
|
689 |
Map<Integer, List<PartnerSecondaryPlanModel>> partnerSecondayPlans = orderRepository
|
| 691 |
.selectPartnerSecondaryGroupByBrand(fofoIdList, startDate.toLocalDate()).stream()
|
690 |
.selectPartnerSecondaryGroupByBrand(fofoIdList, startDate.toLocalDate()).stream()
|
| Line 740... |
Line 739... |
| 740 |
}
|
739 |
}
|
| 741 |
|
740 |
|
| 742 |
ptam.setCollectionTarget(targetCollection);
|
741 |
ptam.setCollectionTarget(targetCollection);
|
| 743 |
}
|
742 |
}
|
| 744 |
if (collectionAchievement.getAmount() != null) {
|
743 |
if (collectionAchievement.getAmount() != null) {
|
| 745 |
totalPartnerAchievementCollection += collectionAchievement.getAmount();
|
744 |
if (authId != null && authId == authUser.getId()) {
|
| 746 |
|
745 |
|
| - |
|
746 |
totalPartnerAchievementCollection += collectionAchievement.getAmount();
|
| - |
|
747 |
}
|
| 747 |
ptam.setCollectionAchievement(collectionAchievement.getAmount());
|
748 |
ptam.setCollectionAchievement(collectionAchievement.getAmount());
|
| 748 |
}
|
749 |
}
|
| 749 |
|
750 |
|
| 750 |
if (authId != null && authId != authUser.getId()) {
|
751 |
if (authId != null && authId != authUser.getId()) {
|
| 751 |
ptam.setAuthUser(authRepository.selectById(authId));
|
752 |
ptam.setAuthUser(authRepository.selectById(authId));
|
| Line 862... |
Line 863... |
| 862 |
|
863 |
|
| 863 |
tm.setTotalPartnerTargetCollection(totalPartnerTargetCollection);
|
864 |
tm.setTotalPartnerTargetCollection(totalPartnerTargetCollection);
|
| 864 |
tm.setTotalPartnerTargetSecondary(totalPartnerTargetSecondary);
|
865 |
tm.setTotalPartnerTargetSecondary(totalPartnerTargetSecondary);
|
| 865 |
tm.setTotalPartnerSecondary(totalPartnerAchievementSecondary);
|
866 |
tm.setTotalPartnerSecondary(totalPartnerAchievementSecondary);
|
| 866 |
tm.setTotalPartnerCollection(totalPartnerAchievementCollection);
|
867 |
tm.setTotalPartnerCollection(totalPartnerAchievementCollection);
|
| 867 |
tm.setTodayCollectionCount(todayCollectionCount);
|
868 |
tm.setTodayCollectionCount((int) todayCollectionCount);
|
| 868 |
|
869 |
|
| 869 |
tm.setTargetAchievement(ptams.stream().sorted(Comparator.comparing(PartnerTargetAchievementModel::getRank))
|
870 |
tm.setTargetAchievement(ptams.stream().sorted(Comparator.comparing(PartnerTargetAchievementModel::getRank))
|
| 870 |
.collect(Collectors.toList()));
|
871 |
.collect(Collectors.toList()));
|
| 871 |
|
872 |
|
| 872 |
}
|
873 |
}
|