| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.time.LocalDateTime;
|
3 |
import java.time.LocalDateTime;
|
| 4 |
import java.util.ArrayList;
|
4 |
import java.util.ArrayList;
|
| - |
|
5 |
import java.util.Arrays;
|
| 5 |
import java.util.List;
|
6 |
import java.util.List;
|
| 6 |
import java.util.Map;
|
7 |
import java.util.Map;
|
| 7 |
import java.util.stream.Collectors;
|
8 |
import java.util.stream.Collectors;
|
| 8 |
|
9 |
|
| 9 |
import javax.servlet.http.HttpServletRequest;
|
10 |
import javax.servlet.http.HttpServletRequest;
|
| Line 17... |
Line 18... |
| 17 |
import org.springframework.web.bind.annotation.RequestBody;
|
18 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 18 |
import org.springframework.web.bind.annotation.RequestMapping;
|
19 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 19 |
import org.springframework.web.bind.annotation.RequestMethod;
|
20 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 20 |
import org.springframework.web.bind.annotation.RequestParam;
|
21 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21 |
|
22 |
|
| - |
|
23 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| - |
|
24 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
25 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 23 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
26 |
import com.spice.profitmandi.dao.entity.catalog.Scheme;
|
| - |
|
27 |
import com.spice.profitmandi.dao.entity.transaction.AddWalletRequest;
|
| 24 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
28 |
import com.spice.profitmandi.dao.entity.user.Lead;
|
| 25 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
29 |
import com.spice.profitmandi.dao.entity.user.LeadActivity;
|
| 26 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
30 |
import com.spice.profitmandi.dao.enumuration.dtr.LeadStatus;
|
| - |
|
31 |
import com.spice.profitmandi.dao.enumuration.transaction.AddWalletRequestStatus;
|
| 27 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
32 |
import com.spice.profitmandi.dao.model.CreateRefferalRequest;
|
| 28 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
33 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.LeadActivityRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
35 |
import com.spice.profitmandi.dao.repository.dtr.LeadRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
36 |
import com.spice.profitmandi.dao.repository.inventory.StateRepository;
|
| - |
|
37 |
import com.spice.profitmandi.service.user.LeadService;
|
| 32 |
import com.spice.profitmandi.web.model.LoginDetails;
|
38 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 33 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
39 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 34 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
40 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 35 |
|
41 |
|
| 36 |
@Controller
|
42 |
@Controller
|
| Line 52... |
Line 58... |
| 52 |
|
58 |
|
| 53 |
@Autowired
|
59 |
@Autowired
|
| 54 |
private CookiesProcessor cookiesProcessor;
|
60 |
private CookiesProcessor cookiesProcessor;
|
| 55 |
|
61 |
|
| 56 |
@Autowired
|
62 |
@Autowired
|
| - |
|
63 |
private LeadService leadService;
|
| - |
|
64 |
|
| - |
|
65 |
@Autowired
|
| 57 |
private MVCResponseSender mvcResponseSender;
|
66 |
private MVCResponseSender mvcResponseSender;
|
| 58 |
|
67 |
|
| - |
|
68 |
List<LeadStatus> status = Arrays.asList(LeadStatus.notInterested, LeadStatus.finalized);
|
| - |
|
69 |
|
| 59 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
70 |
@RequestMapping(value = "/getOpenLead", method = RequestMethod.GET)
|
| 60 |
public String getOpenLead(HttpServletRequest request, Model model) throws Exception {
|
71 |
public String getOpenLead(HttpServletRequest request, Model model) throws Exception {
|
| 61 |
List<Lead> leads = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
72 |
List<Lead> leads = leadRepository.selectAllByStatus(LeadStatus.followUp);
|
| 62 |
List<Integer> authIds = new ArrayList<>();
|
73 |
List<Integer> authIds = new ArrayList<>();
|
| 63 |
if (!leads.isEmpty()) {
|
74 |
if (!leads.isEmpty()) {
|
| Line 82... |
Line 93... |
| 82 |
model.addAttribute("authUsers", authUsers);
|
93 |
model.addAttribute("authUsers", authUsers);
|
| 83 |
|
94 |
|
| 84 |
return "lead";
|
95 |
return "lead";
|
| 85 |
}
|
96 |
}
|
| 86 |
|
97 |
|
| - |
|
98 |
@RequestMapping(value = "/getClosedLead", method = RequestMethod.GET)
|
| - |
|
99 |
public String getClosedLead(HttpServletRequest request,
|
| - |
|
100 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
101 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| - |
|
102 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| - |
|
103 |
throws Exception {
|
| - |
|
104 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| - |
|
105 |
List<Lead> leads = null;
|
| - |
|
106 |
long size = 0;
|
| - |
|
107 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
| - |
|
108 |
size = leadRepository.selectCountByStatus(status);
|
| - |
|
109 |
|
| - |
|
110 |
if (!leads.isEmpty()) {
|
| - |
|
111 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
112 |
for (Lead lead : leads) {
|
| - |
|
113 |
authIds.add(lead.getAssignTo());
|
| - |
|
114 |
}
|
| - |
|
115 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
| - |
|
116 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
117 |
|
| - |
|
118 |
model.addAttribute("leads", leads);
|
| - |
|
119 |
model.addAttribute("start", offset + 1);
|
| - |
|
120 |
model.addAttribute("size", size);
|
| - |
|
121 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
122 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
123 |
|
| - |
|
124 |
if (leads.size() < limit) {
|
| - |
|
125 |
model.addAttribute("end", offset + leads.size());
|
| - |
|
126 |
} else {
|
| - |
|
127 |
model.addAttribute("end", offset + limit);
|
| - |
|
128 |
}
|
| - |
|
129 |
|
| - |
|
130 |
} else {
|
| - |
|
131 |
model.addAttribute("lead", leads);
|
| - |
|
132 |
|
| - |
|
133 |
model.addAttribute("size", size);
|
| - |
|
134 |
}
|
| - |
|
135 |
|
| - |
|
136 |
model.addAttribute("authUsers", authUsers);
|
| - |
|
137 |
return "lead-close";
|
| - |
|
138 |
}
|
| - |
|
139 |
|
| - |
|
140 |
@RequestMapping(value = "/getPaginatedClosedLeads", method = RequestMethod.GET)
|
| - |
|
141 |
public String getPaginatedSchemes(HttpServletRequest request,
|
| - |
|
142 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
143 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| - |
|
144 |
throws ProfitMandiBusinessException {
|
| - |
|
145 |
List<Lead> leads = null;
|
| - |
|
146 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
| - |
|
147 |
|
| - |
|
148 |
if (!leads.isEmpty()) {
|
| - |
|
149 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
150 |
for (Lead lead : leads) {
|
| - |
|
151 |
authIds.add(lead.getAssignTo());
|
| - |
|
152 |
}
|
| - |
|
153 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
| - |
|
154 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
155 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
156 |
model.addAttribute("leads", leads);
|
| - |
|
157 |
|
| - |
|
158 |
} else {
|
| - |
|
159 |
model.addAttribute("leads", leads);
|
| - |
|
160 |
|
| - |
|
161 |
}
|
| - |
|
162 |
return "lead-close-paginated";
|
| - |
|
163 |
}
|
| - |
|
164 |
|
| - |
|
165 |
@RequestMapping(value = "/searchLeads")
|
| - |
|
166 |
public String getClosedLeads(HttpServletRequest request,
|
| - |
|
167 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
168 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| - |
|
169 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| - |
|
170 |
throws ProfitMandiBusinessException {
|
| - |
|
171 |
List<AuthUser> authUsers = authRepository.selectAllActiveUser();
|
| - |
|
172 |
List<Lead> leads = null;
|
| - |
|
173 |
long size = 0;
|
| - |
|
174 |
if (!(searchTerm.equals(""))) {
|
| - |
|
175 |
leads = leadRepository.selectBySearchTerm(status, searchTerm, offset, limit);
|
| - |
|
176 |
if (!(leads.size() == 0)) {
|
| - |
|
177 |
size = leadRepository.selectCountByStatus(status);
|
| - |
|
178 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
179 |
for (Lead lead : leads) {
|
| - |
|
180 |
authIds.add(lead.getAssignTo());
|
| - |
|
181 |
}
|
| - |
|
182 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
| - |
|
183 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
184 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
185 |
model.addAttribute("leads", leads);
|
| - |
|
186 |
model.addAttribute("start", offset + 1);
|
| - |
|
187 |
model.addAttribute("size", size);
|
| - |
|
188 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
189 |
|
| - |
|
190 |
if (leads.size() < limit) {
|
| - |
|
191 |
model.addAttribute("end", offset + leads.size());
|
| - |
|
192 |
} else {
|
| - |
|
193 |
model.addAttribute("end", offset + limit);
|
| - |
|
194 |
}
|
| - |
|
195 |
} else {
|
| - |
|
196 |
throw new ProfitMandiBusinessException("lead", searchTerm, "leads Not Found");
|
| - |
|
197 |
}
|
| - |
|
198 |
} else {
|
| - |
|
199 |
leads = leadRepository.selectAllByStatus(status, offset, limit);
|
| - |
|
200 |
size = leadRepository.selectCountByStatus(status);
|
| - |
|
201 |
|
| - |
|
202 |
if (!leads.isEmpty()) {
|
| - |
|
203 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
204 |
for (Lead lead : leads) {
|
| - |
|
205 |
authIds.add(lead.getAssignTo());
|
| - |
|
206 |
}
|
| - |
|
207 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
| - |
|
208 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
209 |
|
| - |
|
210 |
model.addAttribute("leads", leads);
|
| - |
|
211 |
model.addAttribute("start", offset + 1);
|
| - |
|
212 |
model.addAttribute("size", size);
|
| - |
|
213 |
model.addAttribute("searchTerm", searchTerm);
|
| - |
|
214 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
215 |
|
| - |
|
216 |
if (leads.size() < limit) {
|
| - |
|
217 |
model.addAttribute("end", offset + leads.size());
|
| - |
|
218 |
} else {
|
| - |
|
219 |
model.addAttribute("end", offset + limit);
|
| - |
|
220 |
}
|
| - |
|
221 |
|
| - |
|
222 |
}
|
| - |
|
223 |
}
|
| - |
|
224 |
|
| - |
|
225 |
model.addAttribute("authUsers", authUsers);
|
| - |
|
226 |
return "lead-close";
|
| - |
|
227 |
}
|
| - |
|
228 |
|
| - |
|
229 |
@RequestMapping(value = "/searchLeadPaginated")
|
| - |
|
230 |
public String getSchemeByItemPanigated(HttpServletRequest request,
|
| - |
|
231 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| - |
|
232 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
| - |
|
233 |
@RequestParam(name = "searchTerm", required = false, defaultValue = "") String searchTerm, Model model)
|
| - |
|
234 |
throws ProfitMandiBusinessException {
|
| - |
|
235 |
LOGGER.info("In search Item....");
|
| - |
|
236 |
List<Lead> leads = null;
|
| - |
|
237 |
if (!searchTerm.equals("")) {
|
| - |
|
238 |
leads = leadRepository.selectBySearchTerm(status, searchTerm, offset, limit);
|
| - |
|
239 |
if (!(leads.size() == 0)) {
|
| - |
|
240 |
|
| - |
|
241 |
List<Integer> authIds = new ArrayList<>();
|
| - |
|
242 |
for (Lead lead : leads) {
|
| - |
|
243 |
authIds.add(lead.getAssignTo());
|
| - |
|
244 |
}
|
| - |
|
245 |
Map<Integer, AuthUser> authIdAndAuthUserMap = authRepository.selectAllAuthUserByIds(authIds).stream()
|
| - |
|
246 |
.collect(Collectors.toMap(x -> x.getId(), x -> x));
|
| - |
|
247 |
model.addAttribute("authIdAndAuthUserMap", authIdAndAuthUserMap);
|
| - |
|
248 |
model.addAttribute("leads", leads);
|
| - |
|
249 |
}
|
| - |
|
250 |
}
|
| - |
|
251 |
|
| - |
|
252 |
return "lead-close-paginated";
|
| - |
|
253 |
|
| - |
|
254 |
}
|
| - |
|
255 |
|
| 87 |
@RequestMapping(value = "/getLeadActivity", method = RequestMethod.GET)
|
256 |
@RequestMapping(value = "/getLeadActivity", method = RequestMethod.GET)
|
| 88 |
public String getLeadActivity(HttpServletRequest request, @RequestParam int leadId, Model model) throws Exception {
|
257 |
public String getLeadActivity(HttpServletRequest request, @RequestParam int leadId, Model model) throws Exception {
|
| 89 |
List<LeadActivity> leadActivity = leadActivityRepository.selectBYLeadId(leadId);
|
258 |
List<LeadActivity> leadActivity = leadActivityRepository.selectBYLeadId(leadId);
|
| 90 |
model.addAttribute("leadActivity", leadActivity);
|
259 |
model.addAttribute("leadActivity", leadActivity);
|
| 91 |
return "lead_activity_modal";
|
260 |
return "lead_activity_modal";
|
| Line 107... |
Line 276... |
| 107 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
276 |
lead.setUpdatedTimestamp(LocalDateTime.now());
|
| 108 |
lead.setStatus(createRefferalRequest.getStatus());
|
277 |
lead.setStatus(createRefferalRequest.getStatus());
|
| 109 |
lead.setAssignTo(createRefferalRequest.getAssignTo());
|
278 |
lead.setAssignTo(createRefferalRequest.getAssignTo());
|
| 110 |
lead.setSource(createRefferalRequest.getSource());
|
279 |
lead.setSource(createRefferalRequest.getSource());
|
| 111 |
// change
|
280 |
// change
|
| 112 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
281 |
AuthUser authUser = authRepository.selectByEmailOrMobile("prakash.rai@smartdukaan.com");
|
| 113 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
282 |
String authUserName = authUser.getFirstName() + " " + authUser.getLastName();
|
| 114 |
lead.setCreatedBy(authUserName);
|
283 |
lead.setCreatedBy(authUserName);
|
| 115 |
lead.setAuthId(authUser.getId());
|
284 |
lead.setAuthId(authUser.getId());
|
| 116 |
|
285 |
|
| 117 |
leadRepository.persist(lead);
|
286 |
leadRepository.persist(lead);
|