| Line 612... |
Line 612... |
| 612 |
startDate = LocalDate.now().minusDays(1).atStartOfDay();
|
612 |
startDate = LocalDate.now().minusDays(1).atStartOfDay();
|
| 613 |
endDate = LocalDate.now().minusDays(1).atTime(LocalTime.MAX);
|
613 |
endDate = LocalDate.now().minusDays(1).atTime(LocalTime.MAX);
|
| 614 |
}
|
614 |
}
|
| 615 |
|
615 |
|
| 616 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
616 |
List<PartnerDailyInvestment> partnerDailyInvestments = partnerDailyInvestmentRepository
|
| 617 |
.selectAll(fofoIdList, startDate.minusDays(1).toLocalDate());
|
617 |
.selectAll(fofoIdList, startDate.minusDays(3).toLocalDate());
|
| 618 |
if (!partnerDailyInvestments.isEmpty()) {
|
618 |
if (!partnerDailyInvestments.isEmpty()) {
|
| 619 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
619 |
partnerDailyInvestmentMap = partnerDailyInvestments.stream()
|
| 620 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
620 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 621 |
}
|
621 |
}
|
| 622 |
|
622 |
|
| 623 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(fofoIdList);
|
623 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(fofoIdList);
|
| 624 |
|
624 |
|
| 625 |
Map<Integer, PartnerCollectionPlanModel> collectionPlans = userWalletRepository
|
625 |
Map<Integer, PartnerCollectionPlanModel> collectionPlans = userWalletRepository
|
| 626 |
.getPartnerWiseTargetCollections(fofoIdList, startDate, endDate).stream()
|
626 |
.getPartnerWiseTargetCollections(fofoIdList, startDate).stream()
|
| 627 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
627 |
.collect(Collectors.toMap(x -> x.getFofoId(), x -> x));
|
| 628 |
|
628 |
|
| 629 |
LOGGER.info("collectionPlans {}", collectionPlans);
|
629 |
LOGGER.info("collectionPlans {}", collectionPlans);
|
| 630 |
|
630 |
|
| 631 |
Map<Integer, List<PartnerSecondaryPlanModel>> partnerSecondayPlans = orderRepository
|
631 |
Map<Integer, List<PartnerSecondaryPlanModel>> partnerSecondayPlans = orderRepository
|
| Line 647... |
Line 647... |
| 647 |
ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
|
647 |
ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
|
| 648 |
ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
|
648 |
ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
|
| 649 |
}
|
649 |
}
|
| 650 |
|
650 |
|
| 651 |
if (collectionPlans.get(fofoId) != null) {
|
651 |
if (collectionPlans.get(fofoId) != null) {
|
| - |
|
652 |
PartnerCollectionPlanModel collectionPlan = collectionPlans.get(fofoId);
|
| - |
|
653 |
|
| 652 |
Integer authId = collectionPlans.get(fofoId).getAuthId();
|
654 |
Integer authId = collectionPlan.getAuthId();
|
| 653 |
LOGGER.info("authId" + authId);
|
655 |
LOGGER.info("authId" + authId);
|
| 654 |
if (authId != null && authId == authUser.getId()) {
|
656 |
if (authId != null && authId == authUser.getId()) {
|
| 655 |
|
657 |
|
| - |
|
658 |
if (collectionPlan.getTargetPlan() != null && collectionPlan.getCommittedDate() != null) {
|
| - |
|
659 |
|
| 656 |
if (collectionPlans.get(fofoId).getTargetPlan() != null) {
|
660 |
if (collectionPlan.getCommittedDate().isEqual(startDate)) {
|
| 657 |
totalPartnerTargetCollection += collectionPlans.get(fofoId).getTargetPlan();
|
661 |
totalPartnerTargetCollection += collectionPlan.getTargetPlan();
|
| - |
|
662 |
}
|
| 658 |
}
|
663 |
}
|
| 659 |
if (collectionPlans.get(fofoId).getAchievementPlan() != null) {
|
664 |
if (collectionPlan.getAchievementPlan() != null) {
|
| 660 |
totalPartnerAchievementCollection += collectionPlans.get(fofoId).getAchievementPlan();
|
665 |
totalPartnerAchievementCollection += collectionPlan.getAchievementPlan();
|
| 661 |
}
|
666 |
}
|
| 662 |
|
667 |
|
| 663 |
}
|
668 |
}
|
| 664 |
|
669 |
|
| 665 |
if (authId != null && authId != authUser.getId()) {
|
670 |
if (authId != null && authId != authUser.getId()) {
|
| 666 |
ptam.setAuthUser(authRepository.selectById(authId));
|
671 |
ptam.setAuthUser(authRepository.selectById(authId));
|
| 667 |
ptam.setCollectionColor("red");
|
672 |
ptam.setCollectionColor("red");
|
| 668 |
}
|
673 |
}
|
| 669 |
if (collectionPlans.get(fofoId).getTargetPlan() != null) {
|
674 |
if (collectionPlans.get(fofoId).getTargetPlan() != null) {
|
| 670 |
|
675 |
|
| 671 |
ptam.setCollectionTarget(collectionPlans.get(fofoId).getTargetPlan());
|
676 |
ptam.setCollectionTarget(collectionPlan.getTargetPlan());
|
| 672 |
}
|
677 |
}
|
| 673 |
|
678 |
|
| 674 |
if (collectionPlans.get(fofoId).getAchievementPlan() != null) {
|
679 |
if (collectionPlans.get(fofoId).getAchievementPlan() != null) {
|
| 675 |
ptam.setCollectionAchievement(collectionPlans.get(fofoId).getAchievementPlan());
|
680 |
ptam.setCollectionAchievement(collectionPlan.getAchievementPlan());
|
| - |
|
681 |
}
|
| - |
|
682 |
|
| - |
|
683 |
if (collectionPlan.getCommittedDate() != null) {
|
| - |
|
684 |
|
| - |
|
685 |
ptam.setCollectionCommitmentDate(collectionPlan.getCommittedDate().toLocalDate());
|
| 676 |
}
|
686 |
}
|
| 677 |
}
|
687 |
}
|
| 678 |
|
688 |
|
| 679 |
PartnerSecondaryPlanModel otherPartnerSecondaryPlanModel = null;
|
689 |
PartnerSecondaryPlanModel otherPartnerSecondaryPlanModel = null;
|
| 680 |
Map<String, PartnerSecondaryPlanModel> secondaryModelMap = new HashMap<>();
|
690 |
Map<String, PartnerSecondaryPlanModel> secondaryModelMap = new HashMap<>();
|
| 681 |
if (partnerSecondayPlans.get(fofoId) != null) {
|
691 |
if (partnerSecondayPlans.get(fofoId) != null) {
|
| 682 |
|
692 |
|
| 683 |
long otherBrandSecondary = 0;
|
693 |
long otherBrandSecondary = 0;
|
| 684 |
for (PartnerSecondaryPlanModel pspm : partnerSecondayPlans.get(fofoId)) {
|
694 |
for (PartnerSecondaryPlanModel pspm : partnerSecondayPlans.get(fofoId)) {
|
| 685 |
|
- |
|
| 686 |
Integer authId = pspm.getAuthId();
|
695 |
Integer authId = pspm.getAuthId();
|
| 687 |
|
- |
|
| 688 |
if (!brands.contains(pspm.getBrand())) {
|
696 |
if (!brands.contains(pspm.getBrand())) {
|
| 689 |
if (pspm.getAchievementPlan() != null) {
|
697 |
if (pspm.getAchievementPlan() != null) {
|
| 690 |
otherBrandSecondary += pspm.getAchievementPlan();
|
698 |
otherBrandSecondary += pspm.getAchievementPlan();
|
| 691 |
}
|
699 |
}
|
| 692 |
} else {
|
700 |
} else {
|
| 693 |
otherPartnerSecondaryPlanModel = pspm;
|
701 |
otherPartnerSecondaryPlanModel = pspm;
|
| 694 |
}
|
702 |
}
|
| 695 |
|
703 |
|
| 696 |
if (pspm.getTargetPlan() != null) {
|
704 |
if (pspm.getTargetPlan() != null) {
|
| 697 |
|
- |
|
| 698 |
totalSecondaryPlan += pspm.getTargetPlan();
|
705 |
totalSecondaryPlan += pspm.getTargetPlan();
|
| 699 |
}
|
706 |
}
|
| 700 |
|
707 |
|
| 701 |
if (pspm.getAchievementPlan() != null) {
|
708 |
if (pspm.getAchievementPlan() != null) {
|
| 702 |
totalSecondaryAchivement += pspm.getAchievementPlan();
|
709 |
totalSecondaryAchivement += pspm.getAchievementPlan();
|
| 703 |
}
|
710 |
}
|
| - |
|
711 |
|
| - |
|
712 |
if (pspm.getCommittedDate() != null) {
|
| - |
|
713 |
|
| - |
|
714 |
ptam.setSecondaryCommitmentDate(pspm.getCommittedDate().toLocalDate());
|
| - |
|
715 |
}
|
| 704 |
if (authId != null && authId == authUser.getId()) {
|
716 |
if (authId != null && authId == authUser.getId()) {
|
| 705 |
|
717 |
|
| 706 |
if (pspm.getTargetPlan() != null) {
|
718 |
if (pspm.getTargetPlan() != null && pspm.getCommittedDate() != null) {
|
| 707 |
|
719 |
|
| - |
|
720 |
if (pspm.getCommittedDate().isEqual(startDate)) {
|
| 708 |
totalPartnerTargetSecondary += pspm.getTargetPlan();
|
721 |
totalPartnerTargetSecondary += pspm.getTargetPlan();
|
| - |
|
722 |
}
|
| 709 |
}
|
723 |
}
|
| 710 |
|
724 |
|
| 711 |
if (pspm.getAchievementPlan() != null) {
|
725 |
if (pspm.getAchievementPlan() != null) {
|
| 712 |
totalPartnerAchievementSecondary += pspm.getAchievementPlan();
|
726 |
totalPartnerAchievementSecondary += pspm.getAchievementPlan();
|
| 713 |
}
|
727 |
}
|
| Line 724... |
Line 738... |
| 724 |
if (secondaryModelMap.containsKey("Others")) {
|
738 |
if (secondaryModelMap.containsKey("Others")) {
|
| 725 |
PartnerSecondaryPlanModel psp = secondaryModelMap.get("Others");
|
739 |
PartnerSecondaryPlanModel psp = secondaryModelMap.get("Others");
|
| 726 |
psp.setAchievementPlan(otherBrandSecondary);
|
740 |
psp.setAchievementPlan(otherBrandSecondary);
|
| 727 |
} else {
|
741 |
} else {
|
| 728 |
secondaryModelMap.put("Others", new PartnerSecondaryPlanModel(fofoId, "Others", (long) 0,
|
742 |
secondaryModelMap.put("Others", new PartnerSecondaryPlanModel(fofoId, "Others", (long) 0,
|
| 729 |
otherBrandSecondary, authUser.getId()));
|
743 |
otherBrandSecondary, authUser.getId(), null));
|
| 730 |
}
|
744 |
}
|
| 731 |
for (String brand : brands) {
|
745 |
for (String brand : brands) {
|
| 732 |
|
- |
|
| 733 |
if (!secondaryModelMap.containsKey(brand)) {
|
746 |
if (!secondaryModelMap.containsKey(brand)) {
|
| 734 |
secondaryModelMap.put(brand,
|
747 |
secondaryModelMap.put(brand, new PartnerSecondaryPlanModel(fofoId, brand, (long) 0,
|
| 735 |
new PartnerSecondaryPlanModel(fofoId, brand, (long) 0, (long) 0, authUser.getId()));
|
748 |
(long) 0, authUser.getId(), null));
|
| 736 |
}
|
749 |
}
|
| 737 |
|
- |
|
| 738 |
}
|
750 |
}
|
| 739 |
|
751 |
|
| 740 |
for (Entry<String, PartnerSecondaryPlanModel> secondaryModelEntry : secondaryModelMap.entrySet()) {
|
752 |
for (Entry<String, PartnerSecondaryPlanModel> secondaryModelEntry : secondaryModelMap.entrySet()) {
|
| 741 |
|
- |
|
| 742 |
Integer authId = secondaryModelEntry.getValue().getAuthId();
|
753 |
Integer authId = secondaryModelEntry.getValue().getAuthId();
|
| 743 |
|
- |
|
| 744 |
if (authId != null && authId != authUser.getId()) {
|
754 |
if (authId != null && authId != authUser.getId()) {
|
| 745 |
|
- |
|
| 746 |
secondaryModelEntry.getValue().setAuthUser(authRepository.selectById(authId));
|
755 |
secondaryModelEntry.getValue().setAuthUser(authRepository.selectById(authId));
|
| 747 |
|
- |
|
| 748 |
ptam.setSecondaryColor("red");
|
756 |
ptam.setSecondaryColor("red");
|
| 749 |
}
|
757 |
}
|
| 750 |
|
758 |
|
| 751 |
}
|
759 |
}
|
| 752 |
|
760 |
|
| 753 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
761 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
| 754 |
ptam.setTotalSecondaryPlan(totalSecondaryPlan);
|
762 |
ptam.setTotalSecondaryPlan(totalSecondaryPlan);
|
| 755 |
|
- |
|
| 756 |
ptam.setTotalSecondaryAchievement(totalSecondaryAchivement);
|
763 |
ptam.setTotalSecondaryAchievement(totalSecondaryAchivement);
|
| 757 |
|
764 |
|
| 758 |
} else {
|
765 |
} else {
|
| 759 |
for (String brand : brands) {
|
766 |
for (String brand : brands) {
|
| 760 |
PartnerSecondaryPlanModel pspm = new PartnerSecondaryPlanModel();
|
767 |
PartnerSecondaryPlanModel pspm = new PartnerSecondaryPlanModel();
|
| 761 |
pspm.setAchievementPlan((long) 0);
|
768 |
pspm.setAchievementPlan((long) 0);
|
| 762 |
pspm.setTargetPlan((long) 0);
|
769 |
pspm.setTargetPlan((long) 0);
|
| 763 |
pspm.setBrand(brand);
|
770 |
pspm.setBrand(brand);
|
| 764 |
pspm.setFofoId(fofoId);
|
771 |
pspm.setFofoId(fofoId);
|
| 765 |
secondaryModelMap.put(brand, pspm);
|
772 |
secondaryModelMap.put(brand, pspm);
|
| 766 |
|
- |
|
| 767 |
}
|
773 |
}
|
| 768 |
|
- |
|
| 769 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
774 |
ptam.setPartnerSecondaryModel(secondaryModelMap);
|
| 770 |
|
- |
|
| 771 |
}
|
775 |
}
|
| 772 |
|
776 |
|
| 773 |
ptams.add(ptam);
|
777 |
ptams.add(ptam);
|
| 774 |
|
778 |
|
| 775 |
}
|
779 |
}
|
| Line 797... |
Line 801... |
| 797 |
|
801 |
|
| 798 |
LOGGER.info("ptam" + ptam);
|
802 |
LOGGER.info("ptam" + ptam);
|
| 799 |
|
803 |
|
| 800 |
AuthUser authUser = authRepository.selectByGmailId(ptam.getCreatedBy());
|
804 |
AuthUser authUser = authRepository.selectByGmailId(ptam.getCreatedBy());
|
| 801 |
|
805 |
|
| - |
|
806 |
if (ptam.getCollectionCommitmentDate().isAfter(LocalDate.now())
|
| - |
|
807 |
|| ptam.getCollectionCommitmentDate().isEqual(LocalDate.now())) {
|
| 802 |
PartnerCollectionPlan partnerCollectionPlan = partnerCollectionPlanRepository.selectByLocalDate(LocalDate.now(),
|
808 |
PartnerCollectionPlan partnerCollectionPlan = partnerCollectionPlanRepository
|
| 803 |
ptam.getFofoId(), true);
|
809 |
.selectByLocalDate(LocalDate.now(), ptam.getFofoId(), true);
|
| 804 |
LOGGER.info("pcp" + partnerCollectionPlan);
|
810 |
LOGGER.info("pcp" + partnerCollectionPlan);
|
| 805 |
|
811 |
|
| 806 |
if (partnerCollectionPlan == null) {
|
812 |
if (partnerCollectionPlan == null) {
|
| 807 |
if (ptam.getCollectionTarget() > 0) {
|
813 |
if (ptam.getCollectionTarget() > 0) {
|
| 808 |
|
814 |
|
| 809 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
815 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
| 810 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
816 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
| 811 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
817 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
| 812 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
818 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
| 813 |
partnerCollectionPlan.setActive(true);
|
819 |
partnerCollectionPlan.setActive(true);
|
| 814 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
820 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
| 815 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
821 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| 816 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
- |
|
| 817 |
}
|
- |
|
| 818 |
|
- |
|
| 819 |
} else {
|
- |
|
| 820 |
if (partnerCollectionPlan.getCollectionPlan() != ptam.getCollectionTarget()) {
|
- |
|
| 821 |
float totalCollectionPlan = partnerCollectionPlan.getCollectionPlan() + 10000;
|
- |
|
| 822 |
if (authUser.getId() == partnerCollectionPlan.getAuthId()) {
|
- |
|
| 823 |
if (ptam.getCollectionTarget() >= totalCollectionPlan) {
|
- |
|
| 824 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
822 |
partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
| 825 |
partnerCollectionPlan.setActive(true);
|
- |
|
| 826 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
823 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
| 827 |
} else {
|
- |
|
| 828 |
throw new ProfitMandiBusinessException("collection target", "",
|
- |
|
| 829 |
"collection target should be more than " + totalCollectionPlan);
|
- |
|
| 830 |
}
|
824 |
}
|
| 831 |
|
825 |
|
| 832 |
} else {
|
826 |
} else {
|
| 833 |
|
827 |
|
| - |
|
828 |
if (partnerCollectionPlan.getCollectionPlan() != ptam.getCollectionTarget()) {
|
| - |
|
829 |
float totalCollectionPlan = partnerCollectionPlan.getCollectionPlan() + 10000;
|
| - |
|
830 |
if (authUser.getId() == partnerCollectionPlan.getAuthId()) {
|
| - |
|
831 |
|
| 834 |
if (ptam.getCollectionTarget() >= totalCollectionPlan) {
|
832 |
if (ptam.getCollectionTarget() >= totalCollectionPlan) {
|
| - |
|
833 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
| - |
|
834 |
partnerCollectionPlan.setActive(true);
|
| - |
|
835 |
partnerCollectionPlan
|
| - |
|
836 |
.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
| - |
|
837 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
838 |
} else {
|
| - |
|
839 |
throw new ProfitMandiBusinessException("collection target", "",
|
| - |
|
840 |
"collection target should be more than " + totalCollectionPlan);
|
| - |
|
841 |
}
|
| 835 |
|
842 |
|
| 836 |
partnerCollectionPlan.setActive(false);
|
- |
|
| 837 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 838 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
- |
|
| 839 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
- |
|
| 840 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
- |
|
| 841 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
- |
|
| 842 |
partnerCollectionPlan.setActive(true);
|
- |
|
| 843 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
- |
|
| 844 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 845 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
- |
|
| 846 |
} else {
|
843 |
} else {
|
| - |
|
844 |
|
| - |
|
845 |
if (ptam.getCollectionTarget() >= totalCollectionPlan) {
|
| - |
|
846 |
|
| - |
|
847 |
partnerCollectionPlan.setActive(false);
|
| - |
|
848 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
849 |
partnerCollectionPlan = new PartnerCollectionPlan();
|
| - |
|
850 |
partnerCollectionPlan.setCreateTimestamp(LocalDateTime.now());
|
| - |
|
851 |
partnerCollectionPlan.setAuthId(authUser.getId());
|
| - |
|
852 |
partnerCollectionPlan.setFofoId(ptam.getFofoId());
|
| - |
|
853 |
partnerCollectionPlan.setActive(true);
|
| - |
|
854 |
partnerCollectionPlan
|
| - |
|
855 |
.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| - |
|
856 |
partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
|
| - |
|
857 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
858 |
partnerCollectionPlanRepository.persist(partnerCollectionPlan);
|
| - |
|
859 |
} else {
|
| 847 |
throw new ProfitMandiBusinessException("collection target", "",
|
860 |
throw new ProfitMandiBusinessException("collection target", "",
|
| 848 |
"collection target should be more than " + totalCollectionPlan);
|
861 |
"collection target should be more than " + totalCollectionPlan);
|
| - |
|
862 |
}
|
| 849 |
}
|
863 |
}
|
| 850 |
}
|
864 |
}
|
| - |
|
865 |
|
| - |
|
866 |
if (partnerCollectionPlan.getCommitedTimestamp()
|
| - |
|
867 |
.isBefore(ptam.getCollectionCommitmentDate().atStartOfDay())
|
| - |
|
868 |
&& partnerCollectionPlan.getCollectionPlan() == ptam.getCollectionTarget()) {
|
| - |
|
869 |
partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
|
| - |
|
870 |
partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
871 |
}
|
| 851 |
}
|
872 |
}
|
| - |
|
873 |
} else {
|
| - |
|
874 |
throw new ProfitMandiBusinessException("Date", "",
|
| - |
|
875 |
"you can't select the back date" + ptam.getCollectionCommitmentDate());
|
| 852 |
}
|
876 |
}
|
| 853 |
|
877 |
|
| 854 |
for (Entry<String, PartnerSecondaryPlanModel> pspm : ptam.getPartnerSecondaryModel().entrySet()) {
|
878 |
for (Entry<String, PartnerSecondaryPlanModel> pspm : ptam.getPartnerSecondaryModel().entrySet()) {
|
| 855 |
PartnerSecondaryPlanModel plan = pspm.getValue();
|
- |
|
| 856 |
PartnerSecondaryPlan psp = partnerSecondaryPlanRepository.selectByLocalDateBrand(plan.getBrand(),
|
- |
|
| 857 |
LocalDate.now(), ptam.getFofoId(), true);
|
- |
|
| 858 |
LOGGER.info("psp" + psp);
|
- |
|
| 859 |
|
- |
|
| 860 |
if (psp == null) {
|
- |
|
| 861 |
if (plan.getTargetPlan() > 0) {
|
- |
|
| 862 |
|
- |
|
| 863 |
psp = new PartnerSecondaryPlan();
|
- |
|
| 864 |
psp.setAuthId(authUser.getId());
|
- |
|
| 865 |
psp.setBrand(pspm.getKey());
|
- |
|
| 866 |
psp.setFofoId(pspm.getValue().getFofoId());
|
- |
|
| 867 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
- |
|
| 868 |
psp.setCreateTimestamp(LocalDateTime.now());
|
- |
|
| 869 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
- |
|
| 870 |
psp.setActive(true);
|
- |
|
| 871 |
partnerSecondaryPlanRepository.persist(psp);
|
- |
|
| 872 |
}
|
- |
|
| 873 |
|
879 |
|
| - |
|
880 |
if (ptam.getCollectionCommitmentDate().isAfter(LocalDate.now())
|
| - |
|
881 |
|| ptam.getCollectionCommitmentDate().isEqual(LocalDate.now())) {
|
| - |
|
882 |
PartnerSecondaryPlanModel plan = pspm.getValue();
|
| - |
|
883 |
PartnerSecondaryPlan psp = partnerSecondaryPlanRepository.selectByLocalDateBrand(plan.getBrand(),
|
| - |
|
884 |
LocalDate.now(), ptam.getFofoId(), true);
|
| - |
|
885 |
LOGGER.info("psp" + psp);
|
| - |
|
886 |
|
| 874 |
} else {
|
887 |
if (psp == null) {
|
| 875 |
if (plan.getTargetPlan() != psp.getSecondaryPlan()) {
|
888 |
if (plan.getTargetPlan() > 0) {
|
| - |
|
889 |
|
| 876 |
float totalSecondaryPlan = psp.getSecondaryPlan() + 10000;
|
890 |
psp = new PartnerSecondaryPlan();
|
| 877 |
if (authUser.getId() == plan.getAuthId()) {
|
891 |
psp.setAuthId(authUser.getId());
|
| - |
|
892 |
psp.setBrand(pspm.getKey());
|
| 878 |
if (plan.getTargetPlan() >= totalSecondaryPlan) {
|
893 |
psp.setFofoId(pspm.getValue().getFofoId());
|
| 879 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
894 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
| - |
|
895 |
psp.setCreateTimestamp(LocalDateTime.now());
|
| 880 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
896 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
897 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 881 |
psp.setActive(true);
|
898 |
psp.setActive(true);
|
| 882 |
} else {
|
- |
|
| 883 |
throw new ProfitMandiBusinessException("secondary target", "",
|
899 |
partnerSecondaryPlanRepository.persist(psp);
|
| 884 |
"secondary target should be more than " + totalSecondaryPlan);
|
- |
|
| 885 |
}
|
900 |
}
|
| 886 |
|
901 |
|
| 887 |
} else {
|
902 |
} else {
|
| - |
|
903 |
if (plan.getTargetPlan() != psp.getSecondaryPlan()) {
|
| - |
|
904 |
float totalSecondaryPlan = psp.getSecondaryPlan() + 10000;
|
| - |
|
905 |
if (authUser.getId() == plan.getAuthId()) {
|
| - |
|
906 |
if (plan.getTargetPlan() >= totalSecondaryPlan) {
|
| - |
|
907 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
| - |
|
908 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| - |
|
909 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
910 |
psp.setActive(true);
|
| - |
|
911 |
} else {
|
| - |
|
912 |
throw new ProfitMandiBusinessException("secondary target", "",
|
| - |
|
913 |
"secondary target should be more than " + totalSecondaryPlan);
|
| - |
|
914 |
}
|
| 888 |
|
915 |
|
| 889 |
if (plan.getTargetPlan() >= totalSecondaryPlan) {
|
916 |
} else {
|
| 890 |
|
917 |
|
| 891 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
918 |
if (plan.getTargetPlan() >= totalSecondaryPlan) {
|
| 892 |
psp.setActive(false);
|
- |
|
| 893 |
|
919 |
|
| - |
|
920 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
921 |
psp.setActive(false);
|
| 894 |
psp = new PartnerSecondaryPlan();
|
922 |
psp = new PartnerSecondaryPlan();
|
| 895 |
psp.setAuthId(authUser.getId());
|
923 |
psp.setAuthId(authUser.getId());
|
| 896 |
psp.setBrand(pspm.getKey());
|
924 |
psp.setBrand(pspm.getKey());
|
| 897 |
psp.setFofoId(pspm.getValue().getFofoId());
|
925 |
psp.setFofoId(pspm.getValue().getFofoId());
|
| 898 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
926 |
psp.setSecondaryPlan(pspm.getValue().getTargetPlan());
|
| - |
|
927 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| 899 |
psp.setCreateTimestamp(LocalDateTime.now());
|
928 |
psp.setCreateTimestamp(LocalDateTime.now());
|
| 900 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
929 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| 901 |
psp.setActive(true);
|
930 |
psp.setActive(true);
|
| 902 |
partnerSecondaryPlanRepository.persist(psp);
|
931 |
partnerSecondaryPlanRepository.persist(psp);
|
| 903 |
} else {
|
932 |
} else {
|
| 904 |
throw new ProfitMandiBusinessException("secondary target", "",
|
933 |
throw new ProfitMandiBusinessException("secondary target", "",
|
| 905 |
"secondary target should be more than " + totalSecondaryPlan);
|
934 |
"secondary target should be more than " + totalSecondaryPlan);
|
| - |
|
935 |
}
|
| 906 |
}
|
936 |
}
|
| 907 |
}
|
937 |
}
|
| - |
|
938 |
|
| - |
|
939 |
if (psp.getCommitedTimestamp().isBefore(ptam.getSecondaryCommitmentDate().atStartOfDay())
|
| - |
|
940 |
&& plan.getTargetPlan() == psp.getSecondaryPlan()) {
|
| - |
|
941 |
psp.setCommitedTimestamp(ptam.getSecondaryCommitmentDate().atStartOfDay());
|
| - |
|
942 |
psp.setUpdatedTimestamp(LocalDateTime.now());
|
| - |
|
943 |
}
|
| - |
|
944 |
|
| 908 |
}
|
945 |
}
|
| - |
|
946 |
} else {
|
| - |
|
947 |
throw new ProfitMandiBusinessException("Date", "",
|
| - |
|
948 |
"you can't select the back date" + ptam.getSecondaryCommitmentDate());
|
| 909 |
}
|
949 |
}
|
| - |
|
950 |
|
| 910 |
}
|
951 |
}
|
| 911 |
|
952 |
|
| 912 |
return responseSender.ok(true);
|
953 |
return responseSender.ok(true);
|
| - |
|
954 |
|
| 913 |
}
|
955 |
}
|
| 914 |
|
956 |
|
| 915 |
}
|
957 |
}
|
| 916 |
|
958 |
|