| 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.time.LocalTime;
|
- |
|
| 6 |
import java.util.ArrayList;
|
- |
|
| 7 |
import java.util.Arrays;
|
- |
|
| 8 |
import java.util.Comparator;
|
- |
|
| 9 |
import java.util.HashMap;
|
- |
|
| 10 |
import java.util.List;
|
- |
|
| 11 |
import java.util.Map;
|
- |
|
| 12 |
import java.util.Map.Entry;
|
- |
|
| 13 |
import java.util.Set;
|
- |
|
| 14 |
import java.util.stream.Collectors;
|
- |
|
| 15 |
|
- |
|
| 16 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 17 |
|
- |
|
| 18 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 19 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 20 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 21 |
import org.springframework.format.annotation.DateTimeFormat;
|
- |
|
| 22 |
import org.springframework.http.MediaType;
|
- |
|
| 23 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 24 |
import org.springframework.stereotype.Controller;
|
- |
|
| 25 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 26 |
import org.springframework.ui.Model;
|
- |
|
| 27 |
import org.springframework.web.bind.annotation.RequestBody;
|
- |
|
| 28 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 29 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 30 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 31 |
|
- |
|
| 32 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 33 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
4 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 34 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
5 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 35 |
import com.spice.profitmandi.common.services.mandii.TransactionSummaryResponseOut;
|
- |
|
| 36 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
6 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 37 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
7 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 38 |
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionPlan;
|
8 |
import com.spice.profitmandi.dao.entity.auth.PartnerCollectionPlan;
|
| 39 |
import com.spice.profitmandi.dao.entity.auth.PartnerSecondaryPlan;
|
9 |
import com.spice.profitmandi.dao.entity.auth.PartnerSecondaryPlan;
|
| 40 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
10 |
import com.spice.profitmandi.dao.entity.dtr.User;
|
| 41 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
11 |
import com.spice.profitmandi.dao.entity.dtr.UserAccount;
|
| 42 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
12 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 43 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
13 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 44 |
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
|
14 |
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
|
| 45 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
- |
|
| 46 |
import com.spice.profitmandi.dao.entity.user.FranchiseeActivity;
|
15 |
import com.spice.profitmandi.dao.entity.user.FranchiseeActivity;
|
| 47 |
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
|
16 |
import com.spice.profitmandi.dao.entity.user.FranchiseeVisit;
|
| 48 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
17 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 49 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
18 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
| 50 |
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeActivityStatus;
|
19 |
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeActivityStatus;
|
| 51 |
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeVisitStatus;
|
20 |
import com.spice.profitmandi.dao.enumuration.dtr.FranchiseeVisitStatus;
|
| 52 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
21 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| 53 |
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
|
22 |
import com.spice.profitmandi.dao.enumuration.dtr.StoreTimeline;
|
| 54 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
- |
|
| 55 |
import com.spice.profitmandi.dao.model.OnBoardingTimelineModel;
|
- |
|
| 56 |
import com.spice.profitmandi.dao.model.PartnerCollectionPlanModel;
|
- |
|
| 57 |
import com.spice.profitmandi.dao.model.PartnerSecondaryPlanModel;
|
- |
|
| 58 |
import com.spice.profitmandi.dao.model.PartnerTargetAchievementModel;
|
- |
|
| 59 |
import com.spice.profitmandi.dao.model.TargetModel;
|
- |
|
| 60 |
import com.spice.profitmandi.dao.model.UserCart;
|
23 |
import com.spice.profitmandi.dao.model.*;
|
| 61 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
24 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 62 |
import com.spice.profitmandi.dao.repository.auth.AuthUserPartnerMappingRepository;
|
25 |
import com.spice.profitmandi.dao.repository.auth.AuthUserPartnerMappingRepository;
|
| 63 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionPlanRepository;
|
26 |
import com.spice.profitmandi.dao.repository.auth.PartnerCollectionPlanRepository;
|
| 64 |
import com.spice.profitmandi.dao.repository.auth.PartnerSecondaryPlanRepository;
|
27 |
import com.spice.profitmandi.dao.repository.auth.PartnerSecondaryPlanRepository;
|
| 65 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
28 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 66 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
29 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
- |
|
| 68 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeActivityRepository;
|
- |
|
| 69 |
import com.spice.profitmandi.dao.repository.dtr.FranchiseeVisitRepository;
|
- |
|
| 70 |
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
|
- |
|
| 71 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
- |
|
| 72 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
- |
|
| 73 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
- |
|
| 74 |
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
|
30 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 75 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
31 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
32 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
33 |
import com.spice.profitmandi.dao.repository.transaction.UserWalletRepository;
|
| 78 |
import com.spice.profitmandi.service.user.RetailerService;
|
34 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 79 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
35 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
| 80 |
import com.spice.profitmandi.web.req.CreateFranchiseeRequest;
|
36 |
import com.spice.profitmandi.web.req.CreateFranchiseeRequest;
|
| 81 |
import com.spice.profitmandi.web.res.Partner;
|
37 |
import com.spice.profitmandi.web.res.Partner;
|
| 82 |
|
- |
|
| 83 |
import io.swagger.annotations.ApiImplicitParam;
|
38 |
import io.swagger.annotations.ApiImplicitParam;
|
| 84 |
import io.swagger.annotations.ApiImplicitParams;
|
39 |
import io.swagger.annotations.ApiImplicitParams;
|
| - |
|
40 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
41 |
import org.apache.logging.log4j.Logger;
|
| - |
|
42 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
43 |
import org.springframework.format.annotation.DateTimeFormat;
|
| - |
|
44 |
import org.springframework.http.MediaType;
|
| - |
|
45 |
import org.springframework.http.ResponseEntity;
|
| - |
|
46 |
import org.springframework.stereotype.Controller;
|
| - |
|
47 |
import org.springframework.transaction.annotation.Transactional;
|
| - |
|
48 |
import org.springframework.ui.Model;
|
| - |
|
49 |
import org.springframework.web.bind.annotation.RequestBody;
|
| - |
|
50 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
51 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
52 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
53 |
|
| - |
|
54 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
55 |
import java.time.LocalDate;
|
| - |
|
56 |
import java.time.LocalDateTime;
|
| - |
|
57 |
import java.util.*;
|
| - |
|
58 |
import java.util.Map.Entry;
|
| - |
|
59 |
import java.util.stream.Collectors;
|
| 85 |
|
60 |
|
| 86 |
@Controller
|
61 |
@Controller
|
| 87 |
@Transactional(rollbackFor = Throwable.class)
|
62 |
@Transactional(rollbackFor = Throwable.class)
|
| 88 |
public class LeadController {
|
63 |
public class LeadController {
|
| 89 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
64 |
private static final Logger LOGGER = LogManager.getLogger(LeadController.class);
|
| Line 182... |
Line 157... |
| 182 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
157 |
@ApiImplicitParam(name = "Auth-Token", value = "Auth-Token", required = true, dataType = "string", paramType = "header") })
|
| 183 |
public ResponseEntity<?> leadDescription(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
158 |
public ResponseEntity<?> leadDescription(HttpServletRequest request, @RequestParam(name = "gmailId") String gmailId,
|
| 184 |
@RequestParam(name = "status") LeadStatus status) throws ProfitMandiBusinessException {
|
159 |
@RequestParam(name = "status") LeadStatus status) throws ProfitMandiBusinessException {
|
| 185 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
160 |
AuthUser authUser = authRepository.selectByGmailId(gmailId);
|
| 186 |
List<Lead> leads = null;
|
161 |
List<Lead> leads = null;
|
| - |
|
162 |
leads = leadRepository.selectByAssignAuthIdAndStatus(authUser.getId(), status);
|
| 187 |
if (status.equals(LeadStatus.followUp)) {
|
163 |
if (status.equals(LeadStatus.followUp)) {
|
| 188 |
leads = leadRepository.selectLeadsScheduledBetweenDate(Arrays.asList(authUser.getId()),
|
164 |
/*leads = leadRepository.selectLeadsScheduledBetweenDate(Arrays.asList(authUser.getId()),
|
| 189 |
LocalDate.now().atStartOfDay().minusDays(30), LocalDate.now().plusDays(3).atTime(LocalTime.MAX));
|
165 |
LocalDate.now().atStartOfDay().minusDays(30), LocalDate.now().plusDays(30).atTime(LocalTime.MAX));*/
|
| 190 |
} else {
|
- |
|
| 191 |
leads = leadRepository.selectByAssignAuthIdAndStatus(authUser.getId(), status);
|
166 |
Collections.reverse(leads);
|
| 192 |
}
|
167 |
}
|
| 193 |
|
168 |
|
| 194 |
return responseSender.ok(leads);
|
169 |
return responseSender.ok(leads);
|
| 195 |
|
170 |
|
| 196 |
}
|
171 |
}
|