| Line 4... |
Line 4... |
| 4 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
4 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 5 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
5 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 6 |
import com.spice.profitmandi.dao.entity.fofo.TrialBrandPotential;
|
6 |
import com.spice.profitmandi.dao.entity.fofo.TrialBrandPotential;
|
| 7 |
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
|
7 |
import com.spice.profitmandi.dao.entity.fofo.TrialForm;
|
| 8 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
8 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| - |
|
9 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 9 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
10 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 10 |
import com.spice.profitmandi.dao.repository.fofo.TrialBrandPotentialRepository;
|
11 |
import com.spice.profitmandi.dao.repository.fofo.TrialBrandPotentialRepository;
|
| 11 |
import com.spice.profitmandi.dao.repository.trialOnboarding.TrialFormRepository;
|
12 |
import com.spice.profitmandi.dao.repository.trialOnboarding.TrialFormRepository;
|
| 12 |
import com.spice.profitmandi.dao.service.TrialService;
|
13 |
import com.spice.profitmandi.dao.service.TrialService;
|
| - |
|
14 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| - |
|
15 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 13 |
import org.apache.logging.log4j.LogManager;
|
16 |
import org.apache.logging.log4j.LogManager;
|
| 14 |
import org.apache.logging.log4j.Logger;
|
17 |
import org.apache.logging.log4j.Logger;
|
| 15 |
import org.springframework.beans.factory.annotation.Autowired;
|
18 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 16 |
import org.springframework.http.ResponseEntity;
|
19 |
import org.springframework.http.ResponseEntity;
|
| 17 |
import org.springframework.stereotype.Controller;
|
20 |
import org.springframework.stereotype.Controller;
|
| - |
|
21 |
import org.springframework.transaction.annotation.Transactional;
|
| 18 |
import org.springframework.ui.Model;
|
22 |
import org.springframework.ui.Model;
|
| 19 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 20 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 21 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 22 |
import org.springframework.web.bind.annotation.ResponseBody;
|
23 |
import org.springframework.web.bind.annotation.*;
|
| 23 |
|
24 |
|
| 24 |
import javax.servlet.http.HttpServletRequest;
|
25 |
import javax.servlet.http.HttpServletRequest;
|
| 25 |
import org.springframework.transaction.annotation.Transactional;
|
- |
|
| 26 |
import java.time.LocalDateTime;
|
26 |
import java.time.LocalDateTime;
|
| 27 |
import java.util.Collections;
|
27 |
import java.util.Collections;
|
| 28 |
import java.util.List;
|
28 |
import java.util.List;
|
| 29 |
import java.util.Set;
|
29 |
import java.util.Set;
|
| 30 |
import java.util.stream.Collectors;
|
30 |
import java.util.stream.Collectors;
|
| Line 47... |
Line 47... |
| 47 |
TrialFormRepository trialFormRepository;
|
47 |
TrialFormRepository trialFormRepository;
|
| 48 |
|
48 |
|
| 49 |
@Autowired
|
49 |
@Autowired
|
| 50 |
TrialService trialService;
|
50 |
TrialService trialService;
|
| 51 |
|
51 |
|
| - |
|
52 |
@Autowired
|
| - |
|
53 |
CookiesProcessor cookiesProcessor;
|
| - |
|
54 |
|
| - |
|
55 |
@Autowired
|
| - |
|
56 |
AuthRepository authRepository;
|
| - |
|
57 |
|
| - |
|
58 |
|
| 52 |
@RequestMapping(value = "/trial/pending", method = RequestMethod.GET)
|
59 |
@RequestMapping(value = "/trial/pending", method = RequestMethod.GET)
|
| 53 |
public String getTrialPending(HttpServletRequest request, Model model) throws Exception {
|
60 |
public String getTrialPending(HttpServletRequest request, Model model) throws Exception {
|
| 54 |
List<TrialForm> trialForms = trialFormRepository.selectAllByStatus(ProfitMandiConstants.Status.PENDING);
|
61 |
List<TrialForm> trialForms = trialFormRepository.selectAllByStatus(ProfitMandiConstants.Status.PENDING);
|
| 55 |
LOGGER.info("trialForms {}", trialForms.size());
|
62 |
LOGGER.info("trialForms {}", trialForms.size());
|
| 56 |
Set<AuthUser> bmAuthUsers = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Collections.singletonList(EscalationType.L2)).stream().filter(x -> x.isActive()).collect(Collectors.toSet());
|
63 |
Set<AuthUser> bmAuthUsers = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Collections.singletonList(EscalationType.L2)).stream().filter(x -> x.isActive()).collect(Collectors.toSet());
|
| 57 |
Set<AuthUser> asmAuthUsers = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Collections.singletonList(EscalationType.L1)).stream().filter(x -> x.isActive()).collect(Collectors.toSet());
|
64 |
Set<AuthUser> asmAuthUsers = csService.getAuthUserIds(ProfitMandiConstants.TICKET_CATEGORY_SALES, Collections.singletonList(EscalationType.L1)).stream().filter(x -> x.isActive()).collect(Collectors.toSet());
|
| 58 |
LOGGER.info("bm {}", bmAuthUsers);
|
65 |
LOGGER.info("bm {}", bmAuthUsers);
|
| 59 |
LOGGER.info("asm {}", asmAuthUsers);
|
66 |
LOGGER.info("asm {}", asmAuthUsers);
|
| - |
|
67 |
asmAuthUsers.addAll(bmAuthUsers);
|
| 60 |
model.addAttribute("bm", bmAuthUsers);
|
68 |
model.addAttribute("bm", bmAuthUsers);
|
| 61 |
model.addAttribute("asm", asmAuthUsers);
|
69 |
model.addAttribute("asm", asmAuthUsers);
|
| 62 |
model.addAttribute("trialForms", trialForms);
|
70 |
model.addAttribute("trialForms", trialForms);
|
| 63 |
return "trial-form";
|
71 |
return "trial-form";
|
| 64 |
}
|
72 |
}
|
| 65 |
|
73 |
|
| - |
|
74 |
@RequestMapping(value = "/trial/all-trial", method = RequestMethod.GET)
|
| - |
|
75 |
public String getAllTrialUser(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
76 |
List<TrialForm> trialForms = trialFormRepository.selectAll();
|
| - |
|
77 |
LOGGER.info("trialForms {}", trialForms.size());
|
| - |
|
78 |
model.addAttribute("trialForms", trialForms);
|
| - |
|
79 |
return "all-trial-form";
|
| - |
|
80 |
}
|
| - |
|
81 |
|
| 66 |
@RequestMapping(value = "/trial/verified", method = RequestMethod.GET)
|
82 |
@RequestMapping(value = "/trial/verified", method = RequestMethod.GET)
|
| 67 |
public String verifiedTrial(HttpServletRequest request, Model model) throws Exception {
|
83 |
public String verifiedTrial(HttpServletRequest request, Model model) throws Exception {
|
| - |
|
84 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
85 |
|
| - |
|
86 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
| 68 |
List<TrialForm> trialForms = trialFormRepository.selectAllByStatus(ProfitMandiConstants.Status.VERIFIED);
|
87 |
List<TrialForm> trialForms = trialFormRepository.selectAllByStatus(ProfitMandiConstants.Status.VERIFIED);
|
| - |
|
88 |
List<TrialForm> filteredTrialForms = trialForms.stream()
|
| - |
|
89 |
.filter(trialForm ->
|
| - |
|
90 |
(trialForm.getBmId() != null && trialForm.getBmId().equals(authUser.getId())) ||
|
| - |
|
91 |
(trialForm.getAsmId() != null && trialForm.getAsmId().equals(authUser.getId()))
|
| - |
|
92 |
)
|
| - |
|
93 |
.collect(Collectors.toList());
|
| 69 |
LOGGER.info("trialForms {}", trialForms.size());
|
94 |
LOGGER.info("trialForms {}", trialForms.size());
|
| - |
|
95 |
LOGGER.info("filtered trialForms {}", filteredTrialForms);
|
| 70 |
model.addAttribute("trialForms", trialForms);
|
96 |
model.addAttribute("trialForms", filteredTrialForms);
|
| 71 |
return "trial-verified";
|
97 |
return "trial-verified";
|
| 72 |
}
|
98 |
}
|
| 73 |
|
99 |
|
| 74 |
@RequestMapping(value = "/trial/asm-bm", method = RequestMethod.POST)
|
100 |
@RequestMapping(value = "/trial/asm-bm", method = RequestMethod.POST)
|
| 75 |
@ResponseBody
|
101 |
@ResponseBody
|
| Line 92... |
Line 118... |
| 92 |
public String getTrialPending(HttpServletRequest request, Model model, @PathVariable int trialFormId) throws Exception {
|
118 |
public String getTrialPending(HttpServletRequest request, Model model, @PathVariable int trialFormId) throws Exception {
|
| 93 |
TrialForm trialForm = trialFormRepository.selectById(trialFormId);
|
119 |
TrialForm trialForm = trialFormRepository.selectById(trialFormId);
|
| 94 |
return "trial-form";
|
120 |
return "trial-form";
|
| 95 |
}
|
121 |
}
|
| 96 |
|
122 |
|
| 97 |
@RequestMapping(value = "/trial/reject/{trialFormId}", method = RequestMethod.POST)
|
123 |
@RequestMapping(value = "/trial/reject", method = RequestMethod.POST)
|
| 98 |
public String rejectTrialUser(HttpServletRequest request, Model model, @PathVariable int trialFormId) throws Exception {
|
124 |
public ResponseEntity<?> rejectTrialUser(HttpServletRequest request, @RequestParam int trialFormId,
|
| - |
|
125 |
@RequestParam String remark) throws Exception {
|
| 99 |
TrialForm trialForm = trialFormRepository.selectById(trialFormId);
|
126 |
TrialForm trialForm = trialFormRepository.selectById(trialFormId);
|
| 100 |
trialForm.setStatus(ProfitMandiConstants.Status.REJECTED);
|
127 |
trialForm.setStatus(ProfitMandiConstants.Status.REJECTED);
|
| - |
|
128 |
trialForm.setRemark(remark);
|
| 101 |
trialService.sentRejectionMailToTrialUser(trialForm);
|
129 |
trialService.sentRejectionMailToTrialUser(trialForm);
|
| 102 |
|
- |
|
| 103 |
return "trial-form";
|
130 |
return responseSender.ok("Rejected Successfully");
|
| 104 |
}
|
131 |
}
|
| 105 |
|
132 |
|
| 106 |
@RequestMapping(value = "/trial/approve/{trialFormId}", method = RequestMethod.POST)
|
133 |
@RequestMapping(value = "/trial/approve/{trialFormId}", method = RequestMethod.POST)
|
| 107 |
public String approveTrialUser(HttpServletRequest request, Model model, @PathVariable int trialFormId) throws Exception {
|
134 |
public String approveTrialUser(HttpServletRequest request, Model model, @PathVariable int trialFormId) throws Exception {
|
| 108 |
TrialForm trialForm = trialFormRepository.selectById(trialFormId);
|
135 |
TrialForm trialForm = trialFormRepository.selectById(trialFormId);
|