Subversion Repositories SmartDukaan

Rev

Rev 30348 | Rev 30426 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 30348 Rev 30416
Line 1... Line 1...
1
package com.spice.profitmandi.web.controller;
1
package com.spice.profitmandi.web.controller;
2
 
2
 
-
 
3
import java.time.LocalDate;
-
 
4
import java.time.LocalDateTime;
-
 
5
import java.util.ArrayList;
-
 
6
import java.util.Arrays;
-
 
7
import java.util.Comparator;
-
 
8
import java.util.HashMap;
-
 
9
import java.util.List;
-
 
10
import java.util.Map;
-
 
11
import java.util.Map.Entry;
-
 
12
import java.util.Set;
-
 
13
import java.util.stream.Collectors;
-
 
14
 
-
 
15
import javax.servlet.http.HttpServletRequest;
-
 
16
 
-
 
17
import org.apache.logging.log4j.LogManager;
-
 
18
import org.apache.logging.log4j.Logger;
-
 
19
import org.springframework.beans.factory.annotation.Autowired;
-
 
20
import org.springframework.format.annotation.DateTimeFormat;
-
 
21
import org.springframework.http.MediaType;
-
 
22
import org.springframework.http.ResponseEntity;
-
 
23
import org.springframework.stereotype.Controller;
-
 
24
import org.springframework.transaction.annotation.Transactional;
-
 
25
import org.springframework.ui.Model;
-
 
26
import org.springframework.web.bind.annotation.RequestBody;
-
 
27
import org.springframework.web.bind.annotation.RequestMapping;
-
 
28
import org.springframework.web.bind.annotation.RequestMethod;
-
 
29
import org.springframework.web.bind.annotation.RequestParam;
-
 
30
 
3
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
31
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
4
import com.spice.profitmandi.common.model.CustomRetailer;
32
import com.spice.profitmandi.common.model.CustomRetailer;
5
import com.spice.profitmandi.common.model.ProfitMandiConstants;
33
import com.spice.profitmandi.common.model.ProfitMandiConstants;
6
import com.spice.profitmandi.common.web.util.ResponseSender;
34
import com.spice.profitmandi.common.web.util.ResponseSender;
7
import com.spice.profitmandi.dao.entity.auth.AuthUser;
35
import com.spice.profitmandi.dao.entity.auth.AuthUser;
8
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionPlan;
36
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionPlan;
-
 
37
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionRemark;
9
import com.spice.profitmandi.dao.entity.auth.PartnerSecondaryPlan;
38
import com.spice.profitmandi.dao.entity.auth.PartnerSecondaryPlan;
-
 
39
import com.spice.profitmandi.dao.entity.cs.Ticket;
-
 
40
import com.spice.profitmandi.dao.entity.cs.TicketCategory;
-
 
41
import com.spice.profitmandi.dao.entity.cs.TicketSubCategory;
10
import com.spice.profitmandi.dao.entity.dtr.User;
42
import com.spice.profitmandi.dao.entity.dtr.User;
11
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
43
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
12
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
44
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
13
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
45
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
14
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
46
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
15
import com.spice.profitmandi.dao.entity.user.FranchiseeActivity;
47
import com.spice.profitmandi.dao.entity.user.FranchiseeActivity;
16
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
48
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
17
import com.spice.profitmandi.dao.entity.user.Lead;
49
import com.spice.profitmandi.dao.entity.user.Lead;
18
import com.spice.profitmandi.dao.entity.user.LeadActivity;
50
import com.spice.profitmandi.dao.entity.user.LeadActivity;
-
 
51
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
19
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeActivityStatus;
52
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeActivityStatus;
20
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeVisitStatus;
53
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeVisitStatus;
21
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
54
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
22
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
55
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
-
 
56
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
-
 
57
import com.spice.profitmandi.dao.model.OnBoardingTimelineModel;
-
 
58
import com.spice.profitmandi.dao.model.PartnerCollectionAchievementModel;
-
 
59
import com.spice.profitmandi.dao.model.PartnerCollectionPlanModel;
-
 
60
import com.spice.profitmandi.dao.model.PartnerCollectionRemarkModel;
-
 
61
import com.spice.profitmandi.dao.model.PartnerSecondaryPlanModel;
-
 
62
import com.spice.profitmandi.dao.model.PartnerTargetAchievementModel;
-
 
63
import com.spice.profitmandi.dao.model.TargetModel;
-
 
64
import com.spice.profitmandi.dao.model.TicketViewModel;
23
import com.spice.profitmandi.dao.model.*;
65
import com.spice.profitmandi.dao.model.UserCart;
24
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
66
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
25
import com.spice.profitmandi.dao.repository.auth.AuthUserPartnerMappingRepository;
67
import com.spice.profitmandi.dao.repository.auth.AuthUserPartnerMappingRepository;
26
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionPlanRepository;
68
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionPlanRepository;
-
 
69
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionRemarkRepository;
27
import com.spice.profitmandi.dao.repository.auth.PartnerSecondaryPlanRepository;
70
import com.spice.profitmandi.dao.repository.auth.PartnerSecondaryPlanRepository;
28
import com.spice.profitmandi.dao.repository.cs.CsService;
71
import com.spice.profitmandi.dao.repository.cs.CsService;
29
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
72
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
-
 
73
import com.spice.profitmandi.dao.repository.cs.TicketCategoryRepository;
-
 
74
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
-
 
75
import com.spice.profitmandi.dao.repository.cs.TicketSubCategoryRepository;
-
 
76
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
-
 
77
import com.spice.profitmandi.dao.repository.dtr.FranchiseeActivityRepository;
-
 
78
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
-
 
79
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
30
import com.spice.profitmandi.dao.repository.dtr.*;
80
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
-
 
81
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
-
 
82
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
-
 
83
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
31
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
84
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
32
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
85
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
33
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
86
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
34
import com.spice.profitmandi.service.PartnerCollectionService;
87
import com.spice.profitmandi.service.PartnerCollectionService;
35
import com.spice.profitmandi.service.user.RetailerService;
88
import com.spice.profitmandi.service.user.RetailerService;
36
import com.spice.profitmandi.service.user.StoreTimelineTatService;
89
import com.spice.profitmandi.service.user.StoreTimelineTatService;
37
import com.spice.profitmandi.web.req.CreateFranchiseeRequest;
90
import com.spice.profitmandi.web.req.CreateFranchiseeRequest;
38
import com.spice.profitmandi.web.res.Partner;
91
import com.spice.profitmandi.web.res.Partner;
-
 
92
 
39
import io.swagger.annotations.ApiImplicitParam;
93
import io.swagger.annotations.ApiImplicitParam;
40
import io.swagger.annotations.ApiImplicitParams;
94
import io.swagger.annotations.ApiImplicitParams;
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.format.annotation.DateTimeFormat;
-
 
45
import org.springframework.http.MediaType;
-
 
46
import org.springframework.http.ResponseEntity;
-
 
47
import org.springframework.stereotype.Controller;
-
 
48
import org.springframework.transaction.annotation.Transactional;
-
 
49
import org.springframework.ui.Model;
-
 
50
import org.springframework.web.bind.annotation.RequestBody;
-
 
51
import org.springframework.web.bind.annotation.RequestMapping;
-
 
52
import org.springframework.web.bind.annotation.RequestMethod;
-
 
53
import org.springframework.web.bind.annotation.RequestParam;
-
 
54
 
-
 
55
import javax.servlet.http.HttpServletRequest;
-
 
56
import java.time.LocalDate;
-
 
57
import java.time.LocalDateTime;
-
 
58
import java.util.*;
-
 
59
import java.util.Map.Entry;
-
 
60
import java.util.stream.Collectors;
-
 
61
 
95
 
62
@Controller
96
@Controller
63
@Transactional(rollbackFor = Throwable.class)
97
@Transactional(rollbackFor = Throwable.class)
64
public class LeadController {
98
public class LeadController {
65
	private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
99
	private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
Line 106... Line 140...
106
	private StoreTimelineTatService storeTimelineTatService;
140
	private StoreTimelineTatService storeTimelineTatService;
107
 
141
 
108
	@Autowired
142
	@Autowired
109
	private PartnerCollectionService partnerCollectionService;
143
	private PartnerCollectionService partnerCollectionService;
110
 
144
 
-
 
145
	@Autowired
-
 
146
	private TicketRepository ticketRepository;
-
 
147
 
-
 
148
	@Autowired
-
 
149
	private TicketCategoryRepository ticketCategoryRepository;
-
 
150
 
-
 
151
	@Autowired
-
 
152
	private TicketSubCategoryRepository ticketSubCategoryRepository;
-
 
153
 
-
 
154
	@Autowired
-
 
155
	private PartnerCollectionRemarkRepository partnerCollectionRemarkRepository;
-
 
156
 
111
	@RequestMapping(value = "/lead", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
157
	@RequestMapping(value = "/lead", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
112
	@ApiImplicitParams({
158
	@ApiImplicitParams({
113
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
159
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
114
	public ResponseEntity<?> LeadUser(HttpServletRequest request,
160
	public ResponseEntity<?> LeadUser(HttpServletRequest request,
115
			@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
161
			@RequestBody CreateRefferalRequest createRefferalRequest) throws Exception {
Line 583... Line 629...
583
		float totalPartnerAchievementSecondary = 0;
629
		float totalPartnerAchievementSecondary = 0;
584
		float totalPartnerAchievementCollection = 0;
630
		float totalPartnerAchievementCollection = 0;
585
		TargetModel tm = new TargetModel();
631
		TargetModel tm = new TargetModel();
586
		Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
632
		Map<Integer, PartnerDailyInvestment> partnerDailyInvestmentMap = new HashMap<>();
587
 
633
 
-
 
634
		Map<Integer, Long> partnerTicketCount = ticketRepository.selectAllOpenTicketsGroupByRetailer();
-
 
635
 
-
 
636
		LOGGER.info("partnerTicketCount {}", partnerTicketCount);
-
 
637
 
588
		List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
638
		List<PartnerTargetAchievementModel> ptams = new ArrayList<>();
589
 
639
 
590
		if (fofoIds.size() > 0 && fofoIds != null) {
640
		if (fofoIds.size() > 0 && fofoIds != null) {
591
			List<Integer> fofoIdl = new ArrayList<>(fofoIds);
641
			List<Integer> fofoIdl = new ArrayList<>(fofoIds);
592
			List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(fofoIdl).stream()
642
			List<Integer> fofoIdList = fofoStoreRepository.selectByRetailerIds(fofoIdl).stream()
Line 638... Line 688...
638
				float totalSecondaryAchivement = 0;
688
				float totalSecondaryAchivement = 0;
639
 
689
 
640
				PartnerTargetAchievementModel ptam = new PartnerTargetAchievementModel();
690
				PartnerTargetAchievementModel ptam = new PartnerTargetAchievementModel();
641
				ptam.setFofoId(fofoId);
691
				ptam.setFofoId(fofoId);
642
				ptam.setBusinessName(customRetailer.getBusinessName());
692
				ptam.setBusinessName(customRetailer.getBusinessName());
-
 
693
				ptam.setMobile(customRetailer.getMobileNumber());
643
 
694
 
644
				if (partnerDailyInvestmentMap.get(fofoId) != null) {
695
				if (partnerDailyInvestmentMap.get(fofoId) != null) {
645
					ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
696
					ptam.setWalletAmount(partnerDailyInvestmentMap.get(fofoId).getWalletAmount());
646
					ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
697
					ptam.setShortInvestment(partnerDailyInvestmentMap.get(fofoId).getShortInvestment());
647
				}
698
				}
648
 
699
 
649
				if (foundCollectionMap.get(fofoId) != null) {
700
				if (foundCollectionMap.get(fofoId) != null) {
650
					PartnerCollectionPlanModel collectionPlan = foundCollectionMap.get(fofoId);
701
					PartnerCollectionPlanModel collectionPlan = foundCollectionMap.get(fofoId);
651
					PartnerCollectionAchievementModel collectionAchievement = collectionAchievementMap.get(fofoId);
702
					PartnerCollectionAchievementModel collectionAchievement = collectionAchievementMap.get(fofoId);
652
 
-
 
-
 
703
					ptam.setRemark(collectionPlan.getRemark());
-
 
704
					ptam.setMessage(collectionPlan.getMessage());
-
 
705
					ptam.setRemarkTimestamp(collectionPlan.getRemarkTimestamp());
653
					ptam.setRank(collectionPlan.getRank());
706
					ptam.setRank(collectionPlan.getRank());
654
					Integer authId = collectionPlan.getAuthId();
707
					Integer authId = collectionPlan.getAuthId();
655
 
708
 
656
					if (collectionPlan.getRank() == 1) {
-
 
657
						ptam.setCollectionColor("#007bff");
-
 
658
					} else if (collectionPlan.getRank() == 2) {
-
 
659
						ptam.setCollectionColor("#ffc107");
-
 
660
					} else if (collectionPlan.getRank() == 3) {
-
 
661
						ptam.setCollectionColor("#dc3545");
-
 
662
					} else if (collectionPlan.getRank() == 4) {
709
					Map<Integer, String> rankColorMap = ProfitMandiConstants.Rank_Color_Map;
663
						ptam.setCollectionColor("#6c757d");
-
 
664
					} else {
710
 
665
						ptam.setCollectionColor("White");
711
					ptam.setCollectionColor(rankColorMap.get(collectionPlan.getRank()));
666
					}
-
 
667
 
712
 
668
					LOGGER.info("authId" + authId);
713
					LOGGER.info("authId" + authId);
669
 
714
 
670
					if (collectionPlan.getTargetPlan() != null && collectionPlan.getCommittedDate() != null) {
715
					if (collectionPlan.getTargetPlan() != null && collectionPlan.getCommittedDate() != null) {
671
						float targetCollection = 0;
716
						float targetCollection = 0;
Line 785... Line 830...
785
						secondaryModelMap.put(brand, pspm);
830
						secondaryModelMap.put(brand, pspm);
786
					}
831
					}
787
					ptam.setPartnerSecondaryModel(secondaryModelMap);
832
					ptam.setPartnerSecondaryModel(secondaryModelMap);
788
				}
833
				}
789
 
834
 
-
 
835
				if (!partnerTicketCount.isEmpty()) {
-
 
836
					if (partnerTicketCount.get(fofoId) != null) {
-
 
837
						ptam.setTicketCount(partnerTicketCount.get(fofoId));
-
 
838
					} else {
-
 
839
						ptam.setTicketCount(0);
-
 
840
 
-
 
841
					}
-
 
842
				}
-
 
843
 
790
				ptams.add(ptam);
844
				ptams.add(ptam);
791
 
845
 
792
			}
846
			}
793
 
847
 
794
			tm.setTotalPartnerTargetCollection(totalPartnerTargetCollection);
848
			tm.setTotalPartnerTargetCollection(totalPartnerTargetCollection);
Line 832... Line 886...
832
					partnerCollectionPlan.setActive(true);
886
					partnerCollectionPlan.setActive(true);
833
					partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
887
					partnerCollectionPlan.setCollectionPlan(ptam.getCollectionTarget());
834
					partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
888
					partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
835
					partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
889
					partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
836
					partnerCollectionPlanRepository.persist(partnerCollectionPlan);
890
					partnerCollectionPlanRepository.persist(partnerCollectionPlan);
-
 
891
 
837
				}
892
				}
838
 
893
 
839
			} else {
894
			} else {
840
 
895
 
841
				if (partnerCollectionPlan.getCollectionPlan() != ptam.getCollectionTarget()) {
896
				if (partnerCollectionPlan.getCollectionPlan() != ptam.getCollectionTarget()) {
Line 884... Line 939...
884
						|| ptam.getCollectionCommitmentDate().atStartOfDay().isAfter(LocalDate.now().atStartOfDay()))
939
						|| ptam.getCollectionCommitmentDate().atStartOfDay().isAfter(LocalDate.now().atStartOfDay()))
885
						&& partnerCollectionPlan.getCollectionPlan() == ptam.getCollectionTarget()) {
940
						&& partnerCollectionPlan.getCollectionPlan() == ptam.getCollectionTarget()) {
886
					partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
941
					partnerCollectionPlan.setCommitedTimestamp(ptam.getCollectionCommitmentDate().atStartOfDay());
887
					partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
942
					partnerCollectionPlan.setUpdatedTimestamp(LocalDateTime.now());
888
				}
943
				}
-
 
944
 
-
 
945
				PartnerCollectionRemark pcr = new PartnerCollectionRemark();
-
 
946
				pcr.setFofoId(ptam.getFofoId());
-
 
947
				pcr.setAuthId(authUser.getId());
-
 
948
				pcr.setMessage("Collection plan for" + ptam.getCollectionCommitmentDate());
-
 
949
				pcr.setRemark(CollectionRemark.COLLECTION_PLAN);
-
 
950
				pcr.setCreateTimestamp(LocalDateTime.now());
-
 
951
				partnerCollectionRemarkRepository.persist(pcr);
889
			}
952
			}
890
		} else {
953
		} else {
891
			throw new ProfitMandiBusinessException("Date", "",
954
			throw new ProfitMandiBusinessException("Date", "",
892
					"you can't select the back date " + ptam.getCollectionCommitmentDate());
955
					"you can't select the back date " + ptam.getCollectionCommitmentDate());
893
		}
956
		}
Line 974... Line 1037...
974
 
1037
 
975
		return responseSender.ok(true);
1038
		return responseSender.ok(true);
976
 
1039
 
977
	}
1040
	}
978
 
1041
 
-
 
1042
	@RequestMapping(value = "/viewTickets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1043
	@ApiImplicitParams({
-
 
1044
 
-
 
1045
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1046
	public ResponseEntity<?> viewTickets(HttpServletRequest request, @RequestParam int fofoId)
-
 
1047
			throws ProfitMandiBusinessException {
-
 
1048
		List<Ticket> tickets = ticketRepository.selectAllOpenTicketByRetailer(fofoId);
-
 
1049
 
-
 
1050
		List<TicketViewModel> viewList = new ArrayList<>();
-
 
1051
		for (Ticket ticket : tickets) {
-
 
1052
 
-
 
1053
			TicketViewModel ticketViewModel = new TicketViewModel();
-
 
1054
			ticketViewModel.setId(ticket.getId());
-
 
1055
			TicketSubCategory ticketSubCategory = ticketSubCategoryRepository.selectById(ticket.getSubCategoryId());
-
 
1056
			TicketCategory ticketCategory = ticketCategoryRepository.selectById(ticketSubCategory.getCategoryId());
-
 
1057
 
-
 
1058
			ticketViewModel.setCategoryName(ticketCategory.getName());
-
 
1059
			ticketViewModel.setSubCategoryName(ticketSubCategory.getName());
-
 
1060
			ticketViewModel.setCreatedTimestamp(ticket.getCreateTimestamp());
-
 
1061
 
-
 
1062
			viewList.add(ticketViewModel);
-
 
1063
		}
-
 
1064
		return responseSender.ok(viewList);
-
 
1065
 
-
 
1066
	}
-
 
1067
 
-
 
1068
	@RequestMapping(value = "/viewRecentTickets", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1069
	@ApiImplicitParams({
-
 
1070
 
-
 
1071
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1072
	public ResponseEntity<?> viewRecentTickets(HttpServletRequest request, @RequestParam int fofoId)
-
 
1073
			throws ProfitMandiBusinessException {
-
 
1074
		List<TicketViewModel> viewList = ticketRepository.selectRecentClosedTicket(fofoId,
-
 
1075
				LocalDateTime.now().minusDays(20));
-
 
1076
 
-
 
1077
		return responseSender.ok(viewList);
-
 
1078
 
-
 
1079
	}
-
 
1080
 
-
 
1081
	@RequestMapping(value = "/createTicket", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1082
	@ApiImplicitParams({
-
 
1083
 
-
 
1084
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1085
	public ResponseEntity<?> createTicket(HttpServletRequest request) throws ProfitMandiBusinessException {
-
 
1086
		List<TicketCategory> ticketCategories = csService.getAllTicketCategotyFromSubCategory();
-
 
1087
		return responseSender.ok(ticketCategories);
-
 
1088
	}
-
 
1089
 
-
 
1090
	@RequestMapping(value = "/getSubCategoriesByCategoryId", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1091
	@ApiImplicitParams({
-
 
1092
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1093
 
-
 
1094
	public ResponseEntity<?> getSubCategoriesByCategoryId(HttpServletRequest request,
-
 
1095
			@RequestParam(name = "categoryId", defaultValue = "0") int categoryId, Model model) {
-
 
1096
		List<TicketSubCategory> ticketSubCategories = ticketSubCategoryRepository.selectAll(categoryId);
-
 
1097
		LOGGER.info(ticketSubCategories);
-
 
1098
		return responseSender.ok(ticketSubCategories);
-
 
1099
	}
-
 
1100
 
-
 
1101
	@RequestMapping(value = "/createTicket", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1102
	@ApiImplicitParams({
-
 
1103
 
-
 
1104
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1105
	public ResponseEntity<?> createTicket(HttpServletRequest request, @RequestParam(name = "categoryId") int categoryId,
-
 
1106
			@RequestParam(name = "subCategoryId") int subCategoryId, @RequestParam(name = "message") String message,
-
 
1107
			@RequestParam(name = "fofoId") int fofoId) throws Exception {
-
 
1108
		List<Ticket> tickets = ticketRepository.selectAllResolvedMarkedTicketByCreator(fofoId);
-
 
1109
		if (tickets.size() > 3 || tickets.size() == 3) {
-
 
1110
			return responseSender.ok(false);
-
 
1111
		} else {
-
 
1112
			csService.createTicket(fofoId, categoryId, subCategoryId, message);
-
 
1113
 
-
 
1114
		}
-
 
1115
		return responseSender.ok(true);
-
 
1116
	}
-
 
1117
 
-
 
1118
	@RequestMapping(value = "/getCollectionRemark", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1119
	@ApiImplicitParams({
-
 
1120
 
-
 
1121
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1122
	public ResponseEntity<?> getCollectionRemark(HttpServletRequest request) throws ProfitMandiBusinessException {
-
 
1123
 
-
 
1124
		return responseSender.ok(CollectionRemark.values());
-
 
1125
	}
-
 
1126
 
-
 
1127
	@RequestMapping(value = "/createPartnerColectionRemark", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
-
 
1128
	@ApiImplicitParams({
-
 
1129
 
-
 
1130
			@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
-
 
1131
	public ResponseEntity<?> createPartnerColectionRemark(HttpServletRequest request,
-
 
1132
			@RequestBody PartnerCollectionRemarkModel partnerCollectionRemarkModel)
-
 
1133
			throws ProfitMandiBusinessException {
-
 
1134
		AuthUser authUser = authRepository.selectByGmailId(partnerCollectionRemarkModel.getGmailId());
-
 
1135
 
-
 
1136
		PartnerCollectionRemark pcr = new PartnerCollectionRemark();
-
 
1137
		pcr.setFofoId(partnerCollectionRemarkModel.getFofoId());
-
 
1138
		pcr.setAuthId(authUser.getId());
-
 
1139
		pcr.setMessage(partnerCollectionRemarkModel.getMessage());
-
 
1140
		pcr.setRemark(partnerCollectionRemarkModel.getRemark());
-
 
1141
		pcr.setCreateTimestamp(LocalDateTime.now());
-
 
1142
		partnerCollectionRemarkRepository.persist(pcr);
-
 
1143
		return responseSender.ok(true);
-
 
1144
 
-
 
1145
	}
979
}
1146
}
980
1147