| 22981 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23494 |
ashik.ali |
3 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 23955 |
govind |
4 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 28825 |
tejbeer |
5 |
import com.spice.profitmandi.common.enumuration.FofoType;
|
| 22981 |
ashik.ali |
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 30017 |
amit.gupta |
7 |
import com.spice.profitmandi.common.model.*;
|
| 28024 |
tejbeer |
8 |
import com.spice.profitmandi.common.util.Utils;
|
| 23330 |
ashik.ali |
9 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 27231 |
tejbeer |
10 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 30017 |
amit.gupta |
11 |
import com.spice.profitmandi.dao.entity.dtr.*;
|
|
|
12 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 24159 |
tejbeer |
13 |
import com.spice.profitmandi.dao.entity.user.Location;
|
|
|
14 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
| 24123 |
tejbeer |
15 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 27231 |
tejbeer |
16 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
17 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 28272 |
tejbeer |
18 |
import com.spice.profitmandi.dao.repository.cs.RetailerBrandsLimitService;
|
| 30017 |
amit.gupta |
19 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 27797 |
tejbeer |
20 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
|
|
21 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 28381 |
tejbeer |
22 |
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
|
| 24123 |
tejbeer |
23 |
import com.spice.profitmandi.dao.repository.user.LocationRepository;
|
| 24159 |
tejbeer |
24 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| 24123 |
tejbeer |
25 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 24349 |
amit.gupta |
26 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 33814 |
ranu |
27 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 32731 |
ranu |
28 |
import com.spice.profitmandi.service.catalog.BrandsService;
|
| 24159 |
tejbeer |
29 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22981 |
ashik.ali |
30 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 28908 |
tejbeer |
31 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
| 25276 |
amit.gupta |
32 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
33 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24123 |
tejbeer |
34 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 30017 |
amit.gupta |
35 |
import org.apache.logging.log4j.LogManager;
|
|
|
36 |
import org.apache.logging.log4j.Logger;
|
|
|
37 |
import org.json.JSONObject;
|
|
|
38 |
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
39 |
import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
40 |
import org.springframework.core.io.InputStreamResource;
|
|
|
41 |
import org.springframework.http.HttpHeaders;
|
|
|
42 |
import org.springframework.http.HttpStatus;
|
|
|
43 |
import org.springframework.http.ResponseEntity;
|
|
|
44 |
import org.springframework.stereotype.Controller;
|
|
|
45 |
import org.springframework.ui.Model;
|
|
|
46 |
import org.springframework.web.bind.annotation.*;
|
| 22981 |
ashik.ali |
47 |
|
| 30017 |
amit.gupta |
48 |
import javax.servlet.http.HttpServletRequest;
|
|
|
49 |
import javax.transaction.Transactional;
|
|
|
50 |
import java.io.File;
|
|
|
51 |
import java.io.FileInputStream;
|
|
|
52 |
import java.io.FileNotFoundException;
|
|
|
53 |
import java.time.LocalDate;
|
|
|
54 |
import java.time.LocalDateTime;
|
|
|
55 |
import java.util.*;
|
|
|
56 |
import java.util.stream.Collectors;
|
|
|
57 |
|
| 22981 |
ashik.ali |
58 |
@Controller
|
| 25277 |
amit.gupta |
59 |
@Transactional(rollbackOn = Throwable.class)
|
| 22981 |
ashik.ali |
60 |
public class RetailerController {
|
|
|
61 |
|
| 23568 |
govind |
62 |
private static final Logger LOGGER = LogManager.getLogger(RetailerController.class);
|
| 24124 |
govind |
63 |
|
| 22981 |
ashik.ali |
64 |
@Autowired
|
|
|
65 |
private RetailerService retailerService;
|
| 24124 |
govind |
66 |
|
| 32667 |
raveendra. |
67 |
|
| 23330 |
ashik.ali |
68 |
@Autowired
|
| 28832 |
tejbeer |
69 |
private RetailerRepository retailerRepository;
|
|
|
70 |
|
| 23494 |
ashik.ali |
71 |
@Autowired
|
| 32751 |
amit.gupta |
72 |
private PincodePartnerRepository pincodePartnerRepository;
|
| 28832 |
tejbeer |
73 |
|
| 28381 |
tejbeer |
74 |
@Autowired
|
| 28272 |
tejbeer |
75 |
private BrandLimitRepository brandLimitRepository;
|
|
|
76 |
|
|
|
77 |
@Autowired
|
|
|
78 |
private RetailerBrandsLimitService retailerBrandsLimitService;
|
|
|
79 |
|
|
|
80 |
@Autowired
|
|
|
81 |
private RetailerBrandsLimitRepository retailerBrandsLimitRepository;
|
|
|
82 |
|
|
|
83 |
@Autowired
|
| 23494 |
ashik.ali |
84 |
private ShopRepository shopRepository;
|
| 24124 |
govind |
85 |
|
| 23494 |
ashik.ali |
86 |
@Autowired
|
| 28024 |
tejbeer |
87 |
private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
|
|
|
88 |
|
|
|
89 |
@Autowired
|
| 24124 |
govind |
90 |
private FofoStoreRepository fofoStoreRepository;
|
|
|
91 |
|
|
|
92 |
@Autowired
|
| 23494 |
ashik.ali |
93 |
private DocumentRepository documentRepository;
|
| 24124 |
govind |
94 |
|
| 23494 |
ashik.ali |
95 |
@Autowired
|
| 25276 |
amit.gupta |
96 |
private CookiesProcessor cookiesProcessor;
|
|
|
97 |
|
|
|
98 |
@Autowired
|
| 24159 |
tejbeer |
99 |
@Qualifier("userUserRepository")
|
| 24123 |
tejbeer |
100 |
private UserRepository userRepository;
|
| 24124 |
govind |
101 |
|
| 24123 |
tejbeer |
102 |
@Autowired
|
| 27231 |
tejbeer |
103 |
private AuthRepository authRepository;
|
|
|
104 |
|
|
|
105 |
@Autowired
|
|
|
106 |
private CsService csService;
|
|
|
107 |
|
|
|
108 |
@Autowired
|
| 24123 |
tejbeer |
109 |
private LocationRepository locationRepository;
|
| 24124 |
govind |
110 |
|
| 24123 |
tejbeer |
111 |
@Autowired
|
| 23330 |
ashik.ali |
112 |
private ResponseSender<?> responseSender;
|
| 24124 |
govind |
113 |
|
| 24123 |
tejbeer |
114 |
@Autowired
|
|
|
115 |
private MVCResponseSender mvcResponseSender;
|
| 24124 |
govind |
116 |
|
| 24159 |
tejbeer |
117 |
@Autowired
|
|
|
118 |
private InventoryService inventoryService;
|
|
|
119 |
|
|
|
120 |
@Autowired
|
|
|
121 |
private PromoterRepository promoterRepository;
|
|
|
122 |
|
|
|
123 |
@Autowired
|
| 24349 |
amit.gupta |
124 |
private PartnerInvestmentService partnerInvestmentService;
|
|
|
125 |
|
|
|
126 |
@Autowired
|
| 24159 |
tejbeer |
127 |
private Mongo mongoClient;
|
|
|
128 |
|
| 27797 |
tejbeer |
129 |
@Autowired
|
|
|
130 |
private PartnerTypeChangeService partnerTypeChangeService;
|
|
|
131 |
|
|
|
132 |
@Autowired
|
|
|
133 |
private PartnerTypeChangeRepository partnerTypeChangeRepository;
|
|
|
134 |
|
| 28908 |
tejbeer |
135 |
@Autowired
|
|
|
136 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
|
|
137 |
|
|
|
138 |
@Autowired
|
|
|
139 |
private StoreTimelineTatService storeTimelineTatService;
|
|
|
140 |
|
| 33814 |
ranu |
141 |
@Autowired
|
|
|
142 |
private RoleManager roleManager;
|
|
|
143 |
|
|
|
144 |
@Autowired
|
|
|
145 |
private RetailerContactRepository retailerContactRepository;
|
|
|
146 |
|
| 23784 |
ashik.ali |
147 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
|
| 24124 |
govind |
148 |
public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request,
|
| 30426 |
tejbeer |
149 |
@RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
|
|
|
150 |
Model model) throws ProfitMandiBusinessException {
|
| 24124 |
govind |
151 |
LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(),
|
|
|
152 |
emailIdOrMobileNumber);
|
| 28071 |
tejbeer |
153 |
|
|
|
154 |
Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
|
|
|
155 |
|
| 26771 |
amit.gupta |
156 |
model.addAllAttributes(map);
|
| 28071 |
tejbeer |
157 |
|
| 23955 |
govind |
158 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 26209 |
tejbeer |
159 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 28825 |
tejbeer |
160 |
|
| 26209 |
tejbeer |
161 |
LOGGER.info("warehouseMap", warehouseMap);
|
|
|
162 |
model.addAttribute("warehouses", warehouseMap);
|
| 28825 |
tejbeer |
163 |
model.addAttribute("fofoTypes", FofoType.values());
|
| 26771 |
amit.gupta |
164 |
if (map.containsKey("retailer")) {
|
|
|
165 |
Retailer retailer = (Retailer) map.get("retailer");
|
|
|
166 |
User user = userRepository.selectById(retailer.getId());
|
|
|
167 |
if (user.getLocation() != null) {
|
|
|
168 |
Location location = locationRepository.selectById(user.getLocation());
|
|
|
169 |
model.addAttribute("locationdetail", location);
|
|
|
170 |
LOGGER.info("location" + location);
|
|
|
171 |
}
|
|
|
172 |
}
|
| 22981 |
ashik.ali |
173 |
return "retailer-details";
|
|
|
174 |
}
|
| 24124 |
govind |
175 |
|
| 23026 |
ashik.ali |
176 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
|
| 24124 |
govind |
177 |
public String updateRetailerDetails(HttpServletRequest request,
|
| 30426 |
tejbeer |
178 |
@RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException {
|
| 23026 |
ashik.ali |
179 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
|
|
|
180 |
Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
|
| 32667 |
raveendra. |
181 |
//retailerService.up
|
| 28071 |
tejbeer |
182 |
|
| 23026 |
ashik.ali |
183 |
model.addAllAttributes(map);
|
| 23955 |
govind |
184 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 26209 |
tejbeer |
185 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
186 |
LOGGER.info("warehouseMap", warehouseMap);
|
|
|
187 |
model.addAttribute("warehouses", warehouseMap);
|
| 28832 |
tejbeer |
188 |
model.addAttribute("fofoTypes", FofoType.values());
|
| 23026 |
ashik.ali |
189 |
return "retailer-details";
|
|
|
190 |
}
|
| 22981 |
ashik.ali |
191 |
|
| 32667 |
raveendra. |
192 |
@RequestMapping(value = "/retailer/update-email", method = RequestMethod.POST)
|
|
|
193 |
public String updateRetailerEmail(@RequestParam("newEmail") String newEmail, @RequestParam("fofoID") int fofoID) throws ProfitMandiBusinessException {
|
|
|
194 |
retailerService.updateRetailerEmail(fofoID, newEmail);
|
|
|
195 |
return "retailer-details";
|
|
|
196 |
}
|
|
|
197 |
|
| 22981 |
ashik.ali |
198 |
@RequestMapping(value = "/retailerInfo", method = RequestMethod.GET)
|
| 24124 |
govind |
199 |
public String retailerInfo(HttpServletRequest request) throws Exception {
|
| 22981 |
ashik.ali |
200 |
return "retailer-info";
|
|
|
201 |
}
|
| 24124 |
govind |
202 |
|
| 23330 |
ashik.ali |
203 |
@RequestMapping(value = "/district/all/stateName", method = RequestMethod.GET)
|
| 24124 |
govind |
204 |
public ResponseEntity<?> getAllDistrict(@RequestParam(name = "stateName") String stateName) {
|
| 23330 |
ashik.ali |
205 |
return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
|
|
|
206 |
}
|
| 24124 |
govind |
207 |
|
| 23494 |
ashik.ali |
208 |
@RequestMapping(value = "/retailerDocument/documentId", method = RequestMethod.GET)
|
| 24124 |
govind |
209 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
| 30426 |
tejbeer |
210 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId,
|
|
|
211 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
|
| 23494 |
ashik.ali |
212 |
Document document = documentRepository.selectById(documentId);
|
| 23499 |
ashik.ali |
213 |
Retailer retailer = retailerRepository.selectById(retailerId);
|
| 24124 |
govind |
214 |
|
|
|
215 |
if (retailer.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
216 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
|
|
|
217 |
}
|
| 24124 |
govind |
218 |
if (retailer.getDocumentId() != documentId) {
|
| 23494 |
ashik.ali |
219 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, documentId, "RTLR_1014");
|
|
|
220 |
}
|
|
|
221 |
return responseSender.ok(document);
|
|
|
222 |
}
|
| 24124 |
govind |
223 |
|
| 23494 |
ashik.ali |
224 |
@RequestMapping(value = "/retailerDocument/download", method = RequestMethod.GET)
|
| 24124 |
govind |
225 |
public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request,
|
| 30426 |
tejbeer |
226 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
|
| 24124 |
govind |
227 |
throws ProfitMandiBusinessException {
|
|
|
228 |
|
| 23499 |
ashik.ali |
229 |
Retailer retailer = retailerRepository.selectById(retailerId);
|
| 24124 |
govind |
230 |
|
|
|
231 |
if (retailer.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
232 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
|
|
|
233 |
}
|
| 24124 |
govind |
234 |
|
| 23494 |
ashik.ali |
235 |
Document document = documentRepository.selectById(retailer.getDocumentId());
|
| 24124 |
govind |
236 |
|
| 23494 |
ashik.ali |
237 |
FileInputStream file = null;
|
|
|
238 |
try {
|
|
|
239 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
240 |
} catch (FileNotFoundException e) {
|
|
|
241 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
242 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
243 |
}
|
| 24159 |
tejbeer |
244 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
245 |
// ByteArrayOutputStream();
|
| 24124 |
govind |
246 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
247 |
|
|
|
248 |
final HttpHeaders headers = new HttpHeaders();
|
| 23494 |
ashik.ali |
249 |
String contentType = "";
|
| 24124 |
govind |
250 |
if (document.getContentType() == ContentType.JPEG) {
|
| 23494 |
ashik.ali |
251 |
contentType = "image/jpeg";
|
| 24124 |
govind |
252 |
} else if (document.getContentType() == ContentType.PNG) {
|
| 23494 |
ashik.ali |
253 |
contentType = "image/png";
|
| 24124 |
govind |
254 |
} else if (document.getContentType() == ContentType.PDF) {
|
| 23494 |
ashik.ali |
255 |
contentType = "application/pdf";
|
|
|
256 |
}
|
| 24124 |
govind |
257 |
headers.set("Content-Type", contentType);
|
|
|
258 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
259 |
headers.setContentLength(document.getSize());
|
|
|
260 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
261 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
262 |
|
| 24159 |
tejbeer |
263 |
// return
|
|
|
264 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 23494 |
ashik.ali |
265 |
}
|
| 24124 |
govind |
266 |
|
| 23494 |
ashik.ali |
267 |
@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
|
| 24124 |
govind |
268 |
public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request,
|
| 30426 |
tejbeer |
269 |
@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
|
|
|
270 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
|
| 23494 |
ashik.ali |
271 |
Shop shop = shopRepository.selectById(shopId);
|
| 24124 |
govind |
272 |
|
|
|
273 |
if (shop.getRetailerId() != retailerId) {
|
| 23494 |
ashik.ali |
274 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
|
|
|
275 |
}
|
| 24124 |
govind |
276 |
|
|
|
277 |
if (shop.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
278 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
|
|
|
279 |
}
|
| 24124 |
govind |
280 |
|
| 23494 |
ashik.ali |
281 |
Document document = documentRepository.selectById(shop.getDocumentId());
|
|
|
282 |
return responseSender.ok(document);
|
|
|
283 |
}
|
| 24124 |
govind |
284 |
|
| 23494 |
ashik.ali |
285 |
@RequestMapping(value = "/retailerShopDocument/download", method = RequestMethod.GET)
|
| 24124 |
govind |
286 |
public ResponseEntity<?> downloadRetailerShopDocument(HttpServletRequest request,
|
| 30426 |
tejbeer |
287 |
@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
|
|
|
288 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
|
| 24124 |
govind |
289 |
throws ProfitMandiBusinessException {
|
|
|
290 |
|
| 23494 |
ashik.ali |
291 |
Shop shop = shopRepository.selectById(shopId);
|
| 24124 |
govind |
292 |
|
|
|
293 |
if (shop.getRetailerId() != retailerId) {
|
| 23494 |
ashik.ali |
294 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
|
|
|
295 |
}
|
| 24124 |
govind |
296 |
|
|
|
297 |
if (shop.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
298 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
|
|
|
299 |
}
|
| 24124 |
govind |
300 |
|
| 23494 |
ashik.ali |
301 |
Document document = documentRepository.selectById(shop.getDocumentId());
|
| 24124 |
govind |
302 |
|
| 23494 |
ashik.ali |
303 |
FileInputStream file = null;
|
|
|
304 |
try {
|
|
|
305 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
306 |
} catch (FileNotFoundException e) {
|
|
|
307 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
308 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
309 |
}
|
| 24159 |
tejbeer |
310 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
311 |
// ByteArrayOutputStream();
|
| 24124 |
govind |
312 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
313 |
|
|
|
314 |
final HttpHeaders headers = new HttpHeaders();
|
| 23494 |
ashik.ali |
315 |
String contentType = "";
|
| 24124 |
govind |
316 |
if (document.getContentType() == ContentType.JPEG) {
|
| 23494 |
ashik.ali |
317 |
contentType = "image/jpeg";
|
| 24124 |
govind |
318 |
} else if (document.getContentType() == ContentType.PNG) {
|
| 23494 |
ashik.ali |
319 |
contentType = "image/png";
|
| 24124 |
govind |
320 |
} else if (document.getContentType() == ContentType.PDF) {
|
| 23494 |
ashik.ali |
321 |
contentType = "application/pdf";
|
|
|
322 |
}
|
| 24124 |
govind |
323 |
headers.set("Content-Type", contentType);
|
|
|
324 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
325 |
headers.setContentLength(document.getSize());
|
|
|
326 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
327 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
328 |
|
| 24159 |
tejbeer |
329 |
// return
|
|
|
330 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 23494 |
ashik.ali |
331 |
}
|
| 30017 |
amit.gupta |
332 |
|
| 29267 |
manish |
333 |
@GetMapping(value = "/getstore")
|
| 33247 |
ranu |
334 |
public String getstore(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 30017 |
amit.gupta |
335 |
|
| 29267 |
manish |
336 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
337 |
.collect(Collectors.toList());
|
| 30426 |
tejbeer |
338 |
|
|
|
339 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
340 |
|
|
|
341 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
|
|
342 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
343 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
344 |
|
| 33083 |
amit.gupta |
345 |
//LOGGER.info("fofoIds" + fofoIds);
|
| 29267 |
manish |
346 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
| 33083 |
amit.gupta |
347 |
//LOGGER.info("fofoIdsAndCustomRetailer" + fofoIdsAndCustomRetailer);
|
| 29267 |
manish |
348 |
model.addAttribute("fofoIds", fofoIds);
|
| 24124 |
govind |
349 |
|
| 29267 |
manish |
350 |
return "store";
|
|
|
351 |
|
|
|
352 |
}
|
| 30017 |
amit.gupta |
353 |
|
| 32207 |
amit.gupta |
354 |
private static final List<String> CHANGE_PARTNER_CATEGORY_PERMISSIONS = Arrays.asList("tarun.verma@smartdukaan.com", "kamini.sharma@smartdukaan.com", "shankar.mushra@smartdukaan.com");
|
|
|
355 |
|
| 29267 |
manish |
356 |
@RequestMapping(value = "/getPartnerinfo")
|
| 30426 |
tejbeer |
357 |
public String getPartnerinfo(HttpServletRequest request, @RequestBody SelectStorePartnerInfo selectStorePartnerInfo,
|
| 32207 |
amit.gupta |
358 |
Model model) throws ProfitMandiBusinessException {
|
|
|
359 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 33083 |
amit.gupta |
360 |
//LOGGER.info("selectStorePartnerInfo" + selectStorePartnerInfo.getUserIds());
|
| 29267 |
manish |
361 |
List<FofoStore> fofoStores = fofoStoreRepository.selectByRetailerIds(selectStorePartnerInfo.getUserIds());
|
| 33083 |
amit.gupta |
362 |
//LOGGER.info("fofoStoresInfo" + fofoStores);
|
| 29267 |
manish |
363 |
Map<Integer, Boolean> investments = new HashMap<>();
|
|
|
364 |
|
|
|
365 |
for (FofoStore fofoStore : fofoStores) {
|
|
|
366 |
boolean isOk = false;
|
|
|
367 |
if (fofoStore.getGraceDate() != null && fofoStore.getGraceDate().isAfter(LocalDate.now())) {
|
|
|
368 |
isOk = true;
|
|
|
369 |
} else {
|
|
|
370 |
try {
|
| 31521 |
amit.gupta |
371 |
isOk = partnerInvestmentService.isInvestmentOk(fofoStore.getId(), ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE,
|
| 29267 |
manish |
372 |
ProfitMandiConstants.CUTOFF_INVESTMENT);
|
|
|
373 |
if (fofoStore.getGraceCount() > 0) {
|
|
|
374 |
fofoStore.setGraceDate(null);
|
|
|
375 |
fofoStore.setGraceCount(0);
|
|
|
376 |
}
|
|
|
377 |
} catch (ProfitMandiBusinessException e) {
|
| 30017 |
amit.gupta |
378 |
}
|
| 29267 |
manish |
379 |
}
|
|
|
380 |
investments.put(fofoStore.getId(), isOk);
|
|
|
381 |
}
|
|
|
382 |
|
|
|
383 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(false);
|
|
|
384 |
model.addAttribute("fofoStores", fofoStores);
|
|
|
385 |
model.addAttribute("investments", investments);
|
|
|
386 |
model.addAttribute("customRetailers", customRetailers);
|
| 32207 |
amit.gupta |
387 |
boolean canChangeCategory = CHANGE_PARTNER_CATEGORY_PERMISSIONS.contains(loginDetails.getEmailId());
|
|
|
388 |
model.addAttribute("canChangeCategory", canChangeCategory);
|
| 29267 |
manish |
389 |
|
|
|
390 |
return "store-investment";
|
|
|
391 |
|
|
|
392 |
}
|
| 30017 |
amit.gupta |
393 |
|
| 24124 |
govind |
394 |
@GetMapping(value = "/getAllStores")
|
| 32207 |
amit.gupta |
395 |
public String getAllStores(HttpServletRequest request, Model model) throws Exception {
|
| 24124 |
govind |
396 |
|
| 25276 |
amit.gupta |
397 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive())
|
|
|
398 |
.collect(Collectors.toList());
|
| 24349 |
amit.gupta |
399 |
Map<Integer, Boolean> investments = new HashMap<>();
|
| 24124 |
govind |
400 |
|
| 24349 |
amit.gupta |
401 |
for (FofoStore fofoStore : fofoStores) {
|
|
|
402 |
boolean isOk = false;
|
|
|
403 |
if (fofoStore.getGraceDate() != null && fofoStore.getGraceDate().isAfter(LocalDate.now())) {
|
|
|
404 |
isOk = true;
|
|
|
405 |
} else {
|
|
|
406 |
try {
|
| 31521 |
amit.gupta |
407 |
isOk = partnerInvestmentService.isInvestmentOk(fofoStore.getId(), ProfitMandiConstants.MIN_INVESTMENT_PERCENTAGE,
|
| 25276 |
amit.gupta |
408 |
ProfitMandiConstants.CUTOFF_INVESTMENT);
|
|
|
409 |
if (fofoStore.getGraceCount() > 0) {
|
| 24349 |
amit.gupta |
410 |
fofoStore.setGraceDate(null);
|
|
|
411 |
fofoStore.setGraceCount(0);
|
|
|
412 |
}
|
|
|
413 |
} catch (ProfitMandiBusinessException e) {
|
|
|
414 |
}
|
|
|
415 |
}
|
|
|
416 |
investments.put(fofoStore.getId(), isOk);
|
|
|
417 |
}
|
| 24124 |
govind |
418 |
|
| 26963 |
amit.gupta |
419 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(false);
|
| 24124 |
govind |
420 |
model.addAttribute("fofoStores", fofoStores);
|
| 24349 |
amit.gupta |
421 |
model.addAttribute("investments", investments);
|
| 24124 |
govind |
422 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
423 |
|
| 32207 |
amit.gupta |
424 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
425 |
boolean canChangeCategory = CHANGE_PARTNER_CATEGORY_PERMISSIONS.contains(loginDetails.getEmailId());
|
|
|
426 |
model.addAttribute("canChangeCategory", canChangeCategory);
|
|
|
427 |
|
| 29267 |
manish |
428 |
return "store-investment";
|
| 24124 |
govind |
429 |
|
|
|
430 |
}
|
|
|
431 |
|
| 27797 |
tejbeer |
432 |
@GetMapping(value = "/getPartnerCategory")
|
| 33247 |
ranu |
433 |
public String getPartnerCategory(HttpServletRequest request, @RequestParam int fofoId, Model model) throws ProfitMandiBusinessException {
|
| 27797 |
tejbeer |
434 |
|
|
|
435 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
|
|
436 |
List<PartnerType> partnerTypes = partnerType.nextPartnerTypes();
|
|
|
437 |
LOGGER.info("partnerType" + partnerTypes);
|
|
|
438 |
model.addAttribute("partnerTypes", partnerTypes);
|
|
|
439 |
model.addAttribute("fofoId", fofoId);
|
|
|
440 |
return "partner-category";
|
|
|
441 |
}
|
|
|
442 |
|
|
|
443 |
@PostMapping(value = "/updatePartnerCategory")
|
|
|
444 |
public String updatePartnerCategory(HttpServletRequest request, @RequestParam(name = "fofoId") int fofoId,
|
| 30426 |
tejbeer |
445 |
@RequestParam(name = "partnerType") PartnerType partnerType, Model model) throws Exception {
|
| 27797 |
tejbeer |
446 |
|
|
|
447 |
PartnerTypeChange ptc = new PartnerTypeChange();
|
|
|
448 |
ptc.setFofoId(fofoId);
|
|
|
449 |
ptc.setPartnerType(partnerType);
|
|
|
450 |
ptc.setCreateTimestamp(LocalDate.now().atStartOfDay().plusDays(1));
|
|
|
451 |
partnerTypeChangeRepository.persist(ptc);
|
| 31238 |
amit.gupta |
452 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 27797 |
tejbeer |
453 |
|
|
|
454 |
return "response";
|
|
|
455 |
}
|
|
|
456 |
|
| 24349 |
amit.gupta |
457 |
@GetMapping(value = "/partners")
|
|
|
458 |
public String getStoreName(HttpServletRequest request, Model model, @RequestParam String query) throws Exception {
|
| 31321 |
tejbeer |
459 |
model.addAttribute("response1",
|
|
|
460 |
mvcResponseSender.createResponseString(retailerService.getFofoRetailers(false).values().stream()
|
| 31238 |
amit.gupta |
461 |
.filter(x -> x.getDisplayName().toLowerCase().matches(".*?" + query.toLowerCase() + ".*?"))
|
|
|
462 |
.collect(Collectors.toList())));
|
| 24349 |
amit.gupta |
463 |
return "response";
|
|
|
464 |
}
|
|
|
465 |
|
| 24124 |
govind |
466 |
@PostMapping(value = "/deactivateStore")
|
|
|
467 |
public String deActivateStore(HttpServletRequest request,
|
| 30426 |
tejbeer |
468 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 24124 |
govind |
469 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 25276 |
amit.gupta |
470 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 30964 |
tejbeer |
471 |
if (!Arrays
|
|
|
472 |
.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
|
| 31321 |
tejbeer |
473 |
"rahul.katyal@smartdukaan.com", "tejbeer.kaur@smartdukaan.com", "sm@smartdukaan.com")
|
| 30964 |
tejbeer |
474 |
.contains(loginDetails.getEmailId())) {
|
| 26131 |
tejbeer |
475 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
476 |
"You are not authorise to deactivate retailer");
|
| 25276 |
amit.gupta |
477 |
}
|
| 24843 |
govind |
478 |
fofoStore.setActive(false);
|
| 24124 |
govind |
479 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
| 31238 |
amit.gupta |
480 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 24124 |
govind |
481 |
return "response";
|
|
|
482 |
}
|
| 28825 |
tejbeer |
483 |
|
| 28710 |
amit.gupta |
484 |
@PostMapping(value = "/activateStoreForever")
|
|
|
485 |
public String activateStoreForever(HttpServletRequest request,
|
| 30426 |
tejbeer |
486 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 28710 |
amit.gupta |
487 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
488 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 30964 |
tejbeer |
489 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
|
| 31321 |
tejbeer |
490 |
"rahul.katyal@smartdukaan.com", "sm@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
| 28710 |
amit.gupta |
491 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
492 |
"You are not authorise to activate retailer");
|
|
|
493 |
}
|
|
|
494 |
fofoStore.setActive(true);
|
|
|
495 |
LOGGER.info("inserted into ActiveFofoStore successfully");
|
| 31238 |
amit.gupta |
496 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28710 |
amit.gupta |
497 |
return "response";
|
|
|
498 |
}
|
| 28825 |
tejbeer |
499 |
|
| 28710 |
amit.gupta |
500 |
@PostMapping(value = "/activateStoreTemporary")
|
|
|
501 |
public String activateStoreTemporary(HttpServletRequest request,
|
| 30426 |
tejbeer |
502 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
|
|
|
503 |
@RequestParam(name = "days", required = true) int days, Model model) throws Exception {
|
| 28825 |
tejbeer |
504 |
|
| 28710 |
amit.gupta |
505 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
506 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 30964 |
tejbeer |
507 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
|
| 31321 |
tejbeer |
508 |
"rahul.katyal@smartdukaan.com", "sm@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
| 28710 |
amit.gupta |
509 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
510 |
"You are not authorise to deactivate retailer");
|
|
|
511 |
}
|
| 28825 |
tejbeer |
512 |
|
|
|
513 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
514 |
|
| 28710 |
amit.gupta |
515 |
LocalDateTime EndDate = currentDate.plusDays(days);
|
|
|
516 |
fofoStore.setActiveTimeStamp(EndDate);
|
| 28825 |
tejbeer |
517 |
|
|
|
518 |
LOGGER.info("EndDate" + EndDate);
|
|
|
519 |
LOGGER.info("getActiveTimeStamp" + fofoStore.getActiveTimeStamp());
|
|
|
520 |
|
|
|
521 |
if (currentDate.isBefore(fofoStore.getActiveTimeStamp())) {
|
|
|
522 |
fofoStore.setActive(true);
|
|
|
523 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
| 28710 |
amit.gupta |
524 |
}
|
| 28825 |
tejbeer |
525 |
|
| 31238 |
amit.gupta |
526 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28710 |
amit.gupta |
527 |
return "response";
|
|
|
528 |
}
|
| 25276 |
amit.gupta |
529 |
|
|
|
530 |
@GetMapping(value = "/getAllInactiveStores")
|
| 33247 |
ranu |
531 |
public String getInactiveStores(HttpServletRequest request, Model model) throws ProfitMandiBusinessException {
|
| 25276 |
amit.gupta |
532 |
List<FofoStore> inActiveFofoStores = fofoStoreRepository.selectInActiveStore();
|
| 30426 |
tejbeer |
533 |
|
| 30431 |
tejbeer |
534 |
LOGGER.info("inActiveFofoStores {}", inActiveFofoStores);
|
| 30426 |
tejbeer |
535 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
536 |
|
| 30431 |
tejbeer |
537 |
List<Integer> fofoIds = inActiveFofoStores.stream().map(x -> x.getId()).collect(Collectors.toList());
|
|
|
538 |
|
|
|
539 |
Map<Integer, CustomRetailer> customRetailers = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
| 30426 |
tejbeer |
540 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
541 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 30431 |
tejbeer |
542 |
LOGGER.info("customRetailers {}", customRetailers);
|
| 30426 |
tejbeer |
543 |
|
| 24680 |
govind |
544 |
model.addAttribute("inActiveFofoStores", inActiveFofoStores);
|
|
|
545 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
546 |
return "inactive-stores";
|
|
|
547 |
}
|
| 25276 |
amit.gupta |
548 |
|
|
|
549 |
// Extend billing for 2 days
|
| 24349 |
amit.gupta |
550 |
@PostMapping(value = "/extendBilling")
|
|
|
551 |
public String extendBilling(HttpServletRequest request,
|
| 30426 |
tejbeer |
552 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| 24349 |
amit.gupta |
553 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 25276 |
amit.gupta |
554 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 30963 |
tejbeer |
555 |
if (Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
|
| 33769 |
amit.gupta |
556 |
"rahul.katyal@smartdukaan.com", "sm@smartdukaan.com", "mohit.gulati@smartdukaan.com", "chiranjib.sarkar@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
| 25276 |
amit.gupta |
557 |
fofoStore.setGraceDate(LocalDate.now().plusDays(2));
|
|
|
558 |
fofoStore.setGraceCount(fofoStore.getGraceCount() + 1);
|
| 31238 |
amit.gupta |
559 |
model.addAttribute("response1", mvcResponseSender.createResponseString(fofoStore.getGraceCount()));
|
| 25276 |
amit.gupta |
560 |
} else {
|
| 26131 |
tejbeer |
561 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
562 |
"You are not authorise to extend billing");
|
| 25276 |
amit.gupta |
563 |
}
|
| 24349 |
amit.gupta |
564 |
return "response";
|
| 25276 |
amit.gupta |
565 |
|
| 24124 |
govind |
566 |
}
|
|
|
567 |
|
| 24159 |
tejbeer |
568 |
@RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)
|
| 32887 |
shampa |
569 |
|
|
|
570 |
public String getShowPromoterInfo(HttpServletRequest request,
|
| 30426 |
tejbeer |
571 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
572 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
573 |
@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
|
| 27489 |
tejbeer |
574 |
throws Exception {
|
| 32887 |
shampa |
575 |
//LOGGER.info("requested url : " + request.getRequestURL().toString());
|
| 24159 |
tejbeer |
576 |
List<Promoter> promoterInfo = null;
|
| 32887 |
shampa |
577 |
long size = 0;
|
| 24159 |
tejbeer |
578 |
|
| 32887 |
shampa |
579 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
580 |
.collect(Collectors.toList());
|
|
|
581 |
|
|
|
582 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
583 |
|
|
|
584 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
|
|
585 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
586 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
587 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
|
|
588 |
Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
|
|
589 |
brands.add("Airtel");
|
|
|
590 |
brands.add("Vodafone");
|
|
|
591 |
brands.add("Idea");
|
|
|
592 |
LOGGER.info("brands" + brands);
|
|
|
593 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
594 |
model.addAttribute("brands", brands);
|
|
|
595 |
|
|
|
596 |
if (fofoId != 0) {
|
|
|
597 |
promoterInfo = promoterRepository.selectAllPromoterByFofoIdStatus(fofoId, offset, limit,true);
|
|
|
598 |
|
|
|
599 |
//size = promoterRepository.selectPromoterCount(fofoId);
|
|
|
600 |
size = promoterInfo.size();
|
|
|
601 |
} else {
|
|
|
602 |
//rkb
|
|
|
603 |
promoterInfo = promoterRepository.selectAllPromoterStatus(offset, limit,true);
|
|
|
604 |
|
|
|
605 |
//size = promoterRepository.selectAllCount();
|
|
|
606 |
size = promoterInfo.size();
|
|
|
607 |
}
|
|
|
608 |
if (!promoterInfo.isEmpty()) {
|
|
|
609 |
Set<Integer> partnerIds = new HashSet<>();
|
|
|
610 |
|
|
|
611 |
for (Promoter promoterdetail : promoterInfo) {
|
|
|
612 |
partnerIds.add(promoterdetail.getRetailerId());
|
|
|
613 |
}
|
|
|
614 |
Map<Integer, CustomRetailer> partnersMap = null;
|
|
|
615 |
if (!partnerIds.equals(null)) {
|
|
|
616 |
LOGGER.info("partnerIds" + partnerIds);
|
|
|
617 |
|
|
|
618 |
partnersMap = partnerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
|
|
619 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
620 |
|
|
|
621 |
}
|
|
|
622 |
|
|
|
623 |
LOGGER.info("partnerIds" + partnersMap);
|
|
|
624 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
625 |
model.addAttribute("partnersMap", partnersMap);
|
|
|
626 |
model.addAttribute("start", offset + 1);
|
|
|
627 |
model.addAttribute("size", size);
|
|
|
628 |
model.addAttribute("url", "/getPaginatedPromoterInfo");
|
|
|
629 |
|
|
|
630 |
if (promoterInfo.size() < limit) {
|
|
|
631 |
model.addAttribute("end", offset + promoterInfo.size());
|
|
|
632 |
} else {
|
|
|
633 |
model.addAttribute("end", offset + limit);
|
|
|
634 |
}
|
|
|
635 |
} else {
|
|
|
636 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
637 |
model.addAttribute("size", size);
|
|
|
638 |
}
|
|
|
639 |
return "promoter-info";
|
|
|
640 |
|
|
|
641 |
}
|
|
|
642 |
|
|
|
643 |
|
|
|
644 |
|
|
|
645 |
@RequestMapping(value = "/getPromoterInactive", method = RequestMethod.GET)
|
|
|
646 |
|
|
|
647 |
public String getShowPromoterInactiveInfo(HttpServletRequest request,
|
|
|
648 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
649 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
650 |
@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
|
|
|
651 |
throws Exception {
|
|
|
652 |
//LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
653 |
List<Promoter> promoterInfo = null;
|
| 24159 |
tejbeer |
654 |
long size = 0;
|
| 27489 |
tejbeer |
655 |
|
| 24159 |
tejbeer |
656 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
657 |
.collect(Collectors.toList());
|
| 30426 |
tejbeer |
658 |
|
|
|
659 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
660 |
|
|
|
661 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> customRetailerMap.get(x))
|
|
|
662 |
.filter(x -> x != null).collect(Collectors.toList()).stream()
|
|
|
663 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 24159 |
tejbeer |
664 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| 24986 |
tejbeer |
665 |
Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
|
|
666 |
brands.add("Airtel");
|
|
|
667 |
brands.add("Vodafone");
|
|
|
668 |
brands.add("Idea");
|
| 25276 |
amit.gupta |
669 |
LOGGER.info("brands" + brands);
|
| 24159 |
tejbeer |
670 |
model.addAttribute("customRetailers", customRetailers);
|
| 25276 |
amit.gupta |
671 |
model.addAttribute("brands", brands);
|
| 24159 |
tejbeer |
672 |
|
| 27489 |
tejbeer |
673 |
if (fofoId != 0) {
|
| 32887 |
shampa |
674 |
promoterInfo = promoterRepository.selectAllPromoterByFofoIdStatus(fofoId, offset, limit,false);
|
| 24159 |
tejbeer |
675 |
|
| 32887 |
shampa |
676 |
//size = promoterRepository.selectPromoterCount(fofoId);
|
|
|
677 |
size = promoterInfo.size();
|
| 27489 |
tejbeer |
678 |
|
|
|
679 |
} else {
|
| 32667 |
raveendra. |
680 |
//rkb
|
| 32887 |
shampa |
681 |
promoterInfo = promoterRepository.selectAllPromoterStatus(offset, limit,false);
|
| 27489 |
tejbeer |
682 |
|
| 32887 |
shampa |
683 |
//size = promoterRepository.selectAllCount();
|
|
|
684 |
size = promoterInfo.size();
|
| 27489 |
tejbeer |
685 |
|
|
|
686 |
}
|
| 24159 |
tejbeer |
687 |
if (!promoterInfo.isEmpty()) {
|
| 30944 |
tejbeer |
688 |
Set<Integer> partnerIds = new HashSet<>();
|
| 24159 |
tejbeer |
689 |
|
|
|
690 |
for (Promoter promoterdetail : promoterInfo) {
|
|
|
691 |
partnerIds.add(promoterdetail.getRetailerId());
|
|
|
692 |
}
|
|
|
693 |
Map<Integer, CustomRetailer> partnersMap = null;
|
| 24349 |
amit.gupta |
694 |
if (!partnerIds.equals(null)) {
|
| 24159 |
tejbeer |
695 |
LOGGER.info("partnerIds" + partnerIds);
|
| 30426 |
tejbeer |
696 |
|
|
|
697 |
partnersMap = partnerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
|
|
698 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
699 |
|
| 24159 |
tejbeer |
700 |
}
|
| 24349 |
amit.gupta |
701 |
|
| 24159 |
tejbeer |
702 |
LOGGER.info("partnerIds" + partnersMap);
|
|
|
703 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
704 |
model.addAttribute("partnersMap", partnersMap);
|
|
|
705 |
model.addAttribute("start", offset + 1);
|
|
|
706 |
model.addAttribute("size", size);
|
| 32887 |
shampa |
707 |
model.addAttribute("url", "/getPaginatedPromoterInactiveInfo");
|
| 24159 |
tejbeer |
708 |
|
|
|
709 |
if (promoterInfo.size() < limit) {
|
|
|
710 |
model.addAttribute("end", offset + promoterInfo.size());
|
|
|
711 |
} else {
|
|
|
712 |
model.addAttribute("end", offset + limit);
|
|
|
713 |
}
|
|
|
714 |
} else {
|
|
|
715 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
716 |
model.addAttribute("size", size);
|
|
|
717 |
}
|
| 32887 |
shampa |
718 |
return "promoter-inactive";
|
| 24159 |
tejbeer |
719 |
|
|
|
720 |
}
|
| 24349 |
amit.gupta |
721 |
|
| 32887 |
shampa |
722 |
|
| 24159 |
tejbeer |
723 |
@RequestMapping(value = "/getPaginatedPromoterInfo", method = RequestMethod.GET)
|
|
|
724 |
public String getPaginatedPromoterInfo(HttpServletRequest request,
|
| 30426 |
tejbeer |
725 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
726 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
727 |
@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
|
| 24159 |
tejbeer |
728 |
throws ProfitMandiBusinessException {
|
|
|
729 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
730 |
List<Promoter> promoterInfo = null;
|
| 27489 |
tejbeer |
731 |
if (fofoId != 0) {
|
| 32887 |
shampa |
732 |
promoterInfo = promoterRepository.selectAllPromoterByFofoIdStatus(fofoId, offset, limit,true);
|
| 27489 |
tejbeer |
733 |
} else {
|
| 32887 |
shampa |
734 |
promoterInfo = promoterRepository.selectAllPromoterStatus(offset, limit,true);
|
| 27489 |
tejbeer |
735 |
}
|
| 24159 |
tejbeer |
736 |
LOGGER.info("promoterInfo" + promoterInfo);
|
|
|
737 |
if (!promoterInfo.isEmpty()) {
|
| 30945 |
tejbeer |
738 |
Set<Integer> partnerIds = new HashSet<>();
|
| 24159 |
tejbeer |
739 |
|
|
|
740 |
for (Promoter promoterdetail : promoterInfo) {
|
|
|
741 |
partnerIds.add(promoterdetail.getRetailerId());
|
|
|
742 |
}
|
|
|
743 |
Map<Integer, CustomRetailer> partnersMap = null;
|
| 24349 |
amit.gupta |
744 |
if (!partnerIds.equals(null)) {
|
| 24159 |
tejbeer |
745 |
LOGGER.info("partnerIds" + partnerIds);
|
| 30426 |
tejbeer |
746 |
|
|
|
747 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
748 |
|
|
|
749 |
partnersMap = partnerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
|
|
750 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
751 |
|
| 24159 |
tejbeer |
752 |
}
|
| 24349 |
amit.gupta |
753 |
|
| 24159 |
tejbeer |
754 |
LOGGER.info("partnerIds" + partnersMap);
|
|
|
755 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
756 |
model.addAttribute("partnersMap", partnersMap);
|
|
|
757 |
model.addAttribute("url", "/getPaginatedPromoterInfo");
|
|
|
758 |
} else {
|
|
|
759 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
760 |
|
|
|
761 |
}
|
|
|
762 |
|
|
|
763 |
return "promoter-info-paginated";
|
|
|
764 |
}
|
| 32887 |
shampa |
765 |
@RequestMapping(value = "/getPaginatedPromoterInactiveInfo", method = RequestMethod.GET)
|
|
|
766 |
public String getPaginatedPromoterInactiveInfo(HttpServletRequest request,
|
|
|
767 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
768 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
769 |
@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
|
|
|
770 |
throws ProfitMandiBusinessException {
|
|
|
771 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
772 |
List<Promoter> promoterInfo = null;
|
|
|
773 |
if (fofoId != 0) {
|
|
|
774 |
promoterInfo = promoterRepository.selectAllPromoterByFofoIdStatus(fofoId, offset, limit,false);
|
|
|
775 |
} else {
|
|
|
776 |
promoterInfo = promoterRepository.selectAllPromoterStatus(offset, limit,false);
|
|
|
777 |
}
|
|
|
778 |
LOGGER.info("promoterInfo" + promoterInfo);
|
|
|
779 |
if (!promoterInfo.isEmpty()) {
|
|
|
780 |
Set<Integer> partnerIds = new HashSet<>();
|
| 24159 |
tejbeer |
781 |
|
| 32887 |
shampa |
782 |
for (Promoter promoterdetail : promoterInfo) {
|
|
|
783 |
partnerIds.add(promoterdetail.getRetailerId());
|
|
|
784 |
}
|
|
|
785 |
Map<Integer, CustomRetailer> partnersMap = null;
|
|
|
786 |
if (!partnerIds.equals(null)) {
|
|
|
787 |
LOGGER.info("partnerIds" + partnerIds);
|
|
|
788 |
|
|
|
789 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getAllFofoRetailers();
|
|
|
790 |
|
|
|
791 |
partnersMap = partnerIds.stream().map(x -> customRetailerMap.get(x)).filter(x -> x != null)
|
|
|
792 |
.collect(Collectors.toList()).stream().collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
793 |
|
|
|
794 |
}
|
|
|
795 |
|
|
|
796 |
LOGGER.info("partnerIds" + partnersMap);
|
|
|
797 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
798 |
model.addAttribute("partnersMap", partnersMap);
|
|
|
799 |
model.addAttribute("url", "/getPaginatedPromoterInactiveInfo");
|
|
|
800 |
} else {
|
|
|
801 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
802 |
|
|
|
803 |
}
|
|
|
804 |
|
|
|
805 |
return "promoter-inactive-info-paginated";
|
|
|
806 |
}
|
|
|
807 |
|
| 24159 |
tejbeer |
808 |
@RequestMapping(value = "/createPromoter", method = RequestMethod.POST)
|
|
|
809 |
public String createPromoter(HttpServletRequest request, @RequestBody PromoterDetailModel promoterdetailModel,
|
| 30426 |
tejbeer |
810 |
Model model) throws Exception {
|
| 24159 |
tejbeer |
811 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
812 |
LOGGER.info("requested url : " + promoterdetailModel);
|
| 26131 |
tejbeer |
813 |
Promoter promoter = promoterRepository.selectById(promoterdetailModel.getId());
|
|
|
814 |
if (promoter == null) {
|
|
|
815 |
promoter = new Promoter();
|
| 24159 |
tejbeer |
816 |
promoter.setBrand(promoterdetailModel.getBrand());
|
|
|
817 |
promoter.setRetailerId(promoterdetailModel.getRetailerId());
|
|
|
818 |
promoter.setCreatedTimestamp(LocalDateTime.now());
|
| 28996 |
amit.gupta |
819 |
promoter.setEmail(promoterdetailModel.getEmail());
|
|
|
820 |
promoter.setName(promoterdetailModel.getName());
|
|
|
821 |
promoter.setMobile(promoterdetailModel.getMobile());
|
|
|
822 |
promoter.setSdPortalAccess(promoterdetailModel.isSdPortalAccess());
|
|
|
823 |
promoter.setStatus(promoterdetailModel.isStatus());
|
| 28908 |
tejbeer |
824 |
promoterRepository.persist(promoter);
|
| 26131 |
tejbeer |
825 |
|
| 28908 |
tejbeer |
826 |
List<Promoter> promoters = promoterRepository.selectAllByRetailer(promoterdetailModel.getRetailerId());
|
|
|
827 |
if (!promoters.isEmpty()) {
|
| 28970 |
tejbeer |
828 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(promoterdetailModel.getRetailerId());
|
| 28908 |
tejbeer |
829 |
PartnerOnBoardingPanel pobp = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
|
|
830 |
if (pobp != null) {
|
|
|
831 |
storeTimelineTatService.promoterComplete(pobp.getId());
|
|
|
832 |
}
|
|
|
833 |
}
|
|
|
834 |
|
| 28996 |
amit.gupta |
835 |
} else {
|
|
|
836 |
promoter.setEmail(promoterdetailModel.getEmail());
|
|
|
837 |
promoter.setName(promoterdetailModel.getName());
|
|
|
838 |
promoter.setMobile(promoterdetailModel.getMobile());
|
|
|
839 |
promoter.setSdPortalAccess(promoterdetailModel.isSdPortalAccess());
|
|
|
840 |
promoter.setStatus(promoterdetailModel.isStatus());
|
| 24159 |
tejbeer |
841 |
}
|
| 27489 |
tejbeer |
842 |
LOGGER.info("sdport" + promoterdetailModel.isStatus());
|
| 24159 |
tejbeer |
843 |
|
| 31238 |
amit.gupta |
844 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 24159 |
tejbeer |
845 |
|
|
|
846 |
return "response";
|
|
|
847 |
|
|
|
848 |
}
|
| 32887 |
shampa |
849 |
@RequestMapping(value = "/setPromoterInActive", method = RequestMethod.POST)
|
|
|
850 |
public String PromoterInActive(HttpServletRequest request, @RequestParam(name = "id", required = true, defaultValue = "0") int id, Model model) throws Exception {
|
| 24159 |
tejbeer |
851 |
|
| 32887 |
shampa |
852 |
Promoter promoter = promoterRepository.selectById(id);
|
|
|
853 |
|
|
|
854 |
promoter.setStatus(false);
|
|
|
855 |
|
|
|
856 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
|
|
857 |
|
|
|
858 |
return "response";
|
|
|
859 |
}
|
|
|
860 |
|
|
|
861 |
|
| 24159 |
tejbeer |
862 |
@RequestMapping(value = "/removePromoterfromPartnerStore", method = RequestMethod.POST)
|
|
|
863 |
public String removePromoterfromPartnerStore(HttpServletRequest request,
|
| 30426 |
tejbeer |
864 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
| 24159 |
tejbeer |
865 |
|
|
|
866 |
Promoter promoter = promoterRepository.selectById(id);
|
| 26131 |
tejbeer |
867 |
promoter.setStatus(false);
|
| 32887 |
shampa |
868 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 24159 |
tejbeer |
869 |
|
| 32887 |
shampa |
870 |
return "response";
|
|
|
871 |
}
|
|
|
872 |
@RequestMapping(value = "/activePromoterfromPartnerStore", method = RequestMethod.POST)
|
|
|
873 |
public String activePromoterfromPartnerStore(HttpServletRequest request,
|
|
|
874 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
875 |
|
|
|
876 |
Promoter promoter = promoterRepository.selectById(id);
|
|
|
877 |
promoter.setStatus(true);
|
| 31238 |
amit.gupta |
878 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 24159 |
tejbeer |
879 |
|
|
|
880 |
return "response";
|
|
|
881 |
}
|
|
|
882 |
|
|
|
883 |
@RequestMapping(value = "/addLocation", method = RequestMethod.POST)
|
|
|
884 |
public String addLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel, Model model)
|
|
|
885 |
throws Exception {
|
|
|
886 |
|
|
|
887 |
Location location = new Location();
|
|
|
888 |
location.setName(addLocationModel.getName());
|
|
|
889 |
location.setLine1(addLocationModel.getLine1());
|
|
|
890 |
location.setLine2(addLocationModel.getLine2());
|
|
|
891 |
location.setCity(addLocationModel.getCity());
|
|
|
892 |
location.setState(addLocationModel.getState());
|
|
|
893 |
location.setPin(addLocationModel.getPin());
|
|
|
894 |
|
|
|
895 |
LOGGER.info("PostLocation" + location);
|
|
|
896 |
locationRepository.persist(location);
|
|
|
897 |
|
|
|
898 |
User user = userRepository.selectById(addLocationModel.getUserId());
|
|
|
899 |
user.setLocation(location.getId());
|
|
|
900 |
userRepository.persist(user);
|
|
|
901 |
|
| 31238 |
amit.gupta |
902 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 24159 |
tejbeer |
903 |
return "response";
|
|
|
904 |
|
|
|
905 |
}
|
|
|
906 |
|
|
|
907 |
@RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
|
|
|
908 |
public String updateLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel,
|
| 30426 |
tejbeer |
909 |
Model model) throws Exception {
|
| 24159 |
tejbeer |
910 |
|
|
|
911 |
Location userlocation = locationRepository.selectById(addLocationModel.getUserId());
|
|
|
912 |
|
|
|
913 |
userlocation.setName(addLocationModel.getName());
|
|
|
914 |
userlocation.setCity(addLocationModel.getCity());
|
|
|
915 |
userlocation.setLine1(addLocationModel.getLine1());
|
|
|
916 |
userlocation.setLine2(addLocationModel.getLine2());
|
|
|
917 |
userlocation.setPin(addLocationModel.getPin());
|
|
|
918 |
userlocation.setState(addLocationModel.getState());
|
|
|
919 |
|
|
|
920 |
locationRepository.persist(userlocation);
|
|
|
921 |
|
| 31238 |
amit.gupta |
922 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 24159 |
tejbeer |
923 |
return "response";
|
|
|
924 |
|
|
|
925 |
}
|
|
|
926 |
|
| 27231 |
tejbeer |
927 |
@RequestMapping(value = "/getPartnerReadonlyInfo")
|
|
|
928 |
public String getPartnerReadonlyInfo(HttpServletRequest request, Model model) throws Exception {
|
|
|
929 |
|
|
|
930 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
931 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
932 |
|
|
|
933 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
|
|
934 |
|
| 29633 |
amit.gupta |
935 |
Set<Integer> fofoIds = new HashSet<>(pp.get(authUser.getId()));
|
| 27231 |
tejbeer |
936 |
|
| 30017 |
amit.gupta |
937 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x -> {
|
| 29604 |
amit.gupta |
938 |
try {
|
|
|
939 |
return retailerService.getFofoRetailer(x);
|
|
|
940 |
} catch (ProfitMandiBusinessException e) {
|
|
|
941 |
// TODO Auto-generated catch block
|
|
|
942 |
return null;
|
|
|
943 |
}
|
| 30017 |
amit.gupta |
944 |
}).filter(x -> x != null).collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 27231 |
tejbeer |
945 |
|
|
|
946 |
model.addAttribute("customRetailersMap", customRetailersMap);
|
| 27243 |
tejbeer |
947 |
|
| 27231 |
tejbeer |
948 |
return "partner-readonly-info";
|
|
|
949 |
|
|
|
950 |
}
|
|
|
951 |
|
| 28071 |
tejbeer |
952 |
@RequestMapping(value = "/getBlockBrandMapping")
|
|
|
953 |
public String getBlockBrandMapping(HttpServletRequest request, Model model) throws Exception {
|
|
|
954 |
|
|
|
955 |
int fofoId = Utils.SYSTEM_PARTNER_ID;
|
|
|
956 |
Set<String> brands = null;
|
|
|
957 |
|
|
|
958 |
brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
|
|
959 |
.collect(Collectors.toSet());
|
|
|
960 |
|
|
|
961 |
LOGGER.info("brands" + brands);
|
|
|
962 |
model.addAttribute("brands", brands);
|
|
|
963 |
|
|
|
964 |
return "block-brand-mapping";
|
|
|
965 |
|
|
|
966 |
}
|
|
|
967 |
|
|
|
968 |
@RequestMapping(value = "/getBlockBrand")
|
|
|
969 |
public String getBlockBrand(HttpServletRequest request,
|
| 30426 |
tejbeer |
970 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
| 28071 |
tejbeer |
971 |
throws Exception {
|
|
|
972 |
|
|
|
973 |
List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
|
|
|
974 |
|
|
|
975 |
List<Integer> blockBrandPartners = retailerBlockBrands.stream().map(x -> x.getFofoId())
|
|
|
976 |
.collect(Collectors.toList());
|
|
|
977 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
| 28272 |
tejbeer |
978 |
|
| 28071 |
tejbeer |
979 |
LOGGER.info("retailerBlockBrands" + retailerBlockBrands);
|
|
|
980 |
model.addAttribute("blockBrandPartners", blockBrandPartners);
|
|
|
981 |
model.addAttribute("retailerBlockBrands", retailerBlockBrands);
|
|
|
982 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
983 |
|
|
|
984 |
return "retailer-block-brand";
|
|
|
985 |
|
|
|
986 |
}
|
|
|
987 |
|
|
|
988 |
@RequestMapping(value = "/getRetailerBlockBrandMappping", method = RequestMethod.POST)
|
|
|
989 |
public String getBlockBrandMappping(HttpServletRequest request,
|
| 30426 |
tejbeer |
990 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
991 |
@RequestParam(name = "fofoIds", required = true, defaultValue = "0") List<Integer> fofoIds, Model model)
|
| 28071 |
tejbeer |
992 |
throws Exception {
|
|
|
993 |
List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
|
|
|
994 |
if (!retailerBlockBrands.isEmpty()) {
|
|
|
995 |
retailerBlockBrandsRepository.deleteAllbyBrands(brand);
|
|
|
996 |
}
|
|
|
997 |
|
|
|
998 |
for (int id : fofoIds) {
|
|
|
999 |
RetailerBlockBrands retailerBlockBrand = new RetailerBlockBrands();
|
|
|
1000 |
retailerBlockBrand.setFofoId(id);
|
|
|
1001 |
retailerBlockBrand.setBlockBrands(brand);
|
|
|
1002 |
retailerBlockBrandsRepository.persist(retailerBlockBrand);
|
|
|
1003 |
|
|
|
1004 |
}
|
| 31238 |
amit.gupta |
1005 |
model.addAttribute("response1", mvcResponseSender.createResponseString(true));
|
| 28071 |
tejbeer |
1006 |
|
|
|
1007 |
return "response";
|
|
|
1008 |
}
|
|
|
1009 |
|
| 32731 |
ranu |
1010 |
@Autowired
|
|
|
1011 |
BrandsService brandsService;
|
|
|
1012 |
|
| 28272 |
tejbeer |
1013 |
@RequestMapping(value = "/getBrandslimit", method = RequestMethod.GET)
|
|
|
1014 |
public String getBrandslimit(HttpServletRequest request, Model model) throws Exception {
|
|
|
1015 |
|
|
|
1016 |
int fofoId = Utils.SYSTEM_PARTNER_ID;
|
|
|
1017 |
|
| 32731 |
ranu |
1018 |
List<String> brands = brandsService.getBrandsToDisplay(3).stream().map(x -> x.getName()).collect(Collectors.toList());
|
| 28272 |
tejbeer |
1019 |
model.addAttribute("brands", brands);
|
|
|
1020 |
|
|
|
1021 |
return "brands-limit";
|
|
|
1022 |
|
|
|
1023 |
}
|
|
|
1024 |
|
|
|
1025 |
@RequestMapping(value = "/setUpdateLimit", method = RequestMethod.POST)
|
|
|
1026 |
public String getUpdateLimit(HttpServletRequest request,
|
| 30028 |
manish |
1027 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
1028 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
1029 |
@RequestParam(name = "limit", required = true, defaultValue = "0") float limit,
|
|
|
1030 |
@RequestParam(name = "minStockLimit", required = true, defaultValue = "0") float minStockLimit,
|
|
|
1031 |
@RequestParam(name = "preLimit", required = true, defaultValue = "0") float preLimit,
|
|
|
1032 |
@RequestParam(name = "preStockLimit", required = true, defaultValue = "0") float preStockLimit, Model model)
|
| 28272 |
tejbeer |
1033 |
throws Exception {
|
|
|
1034 |
|
|
|
1035 |
CustomRetailer cr = retailerService.getFofoRetailer(fofoId);
|
| 28277 |
tejbeer |
1036 |
|
|
|
1037 |
Map.Entry<Integer, CustomRetailer> customRetailers = new AbstractMap.SimpleEntry(cr.getPartnerId(), cr);
|
|
|
1038 |
|
|
|
1039 |
// Map<Integer, CustomRetailer> customRetailers =
|
|
|
1040 |
// retailerService.getFofoRetailers(true);
|
| 30028 |
manish |
1041 |
|
| 28272 |
tejbeer |
1042 |
RetailerBrandsLimit retailerBrands = retailerBrandsLimitRepository.selectLimitByBrandAndFofoId(fofoId, brand);
|
| 28277 |
tejbeer |
1043 |
|
| 28272 |
tejbeer |
1044 |
if (retailerBrands == null) {
|
|
|
1045 |
retailerBrands = new RetailerBrandsLimit();
|
| 32736 |
ranu |
1046 |
retailerBrands.setMinStockLimit(minStockLimit);
|
|
|
1047 |
retailerBrands.setBrandLimit(limit);
|
| 28272 |
tejbeer |
1048 |
retailerBrands.setIsUpdate(1);
|
|
|
1049 |
retailerBrands.setCreatedTimestamp(LocalDateTime.now());
|
|
|
1050 |
retailerBrands.setPartnerId(fofoId);
|
|
|
1051 |
retailerBrands.setBrandName(brand);
|
|
|
1052 |
retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1053 |
retailerBrandsLimitRepository.persist(retailerBrands);
|
| 30028 |
manish |
1054 |
} else {
|
| 32736 |
ranu |
1055 |
retailerBrands.setMinStockLimit(minStockLimit);
|
|
|
1056 |
retailerBrands.setBrandLimit(limit);
|
| 28272 |
tejbeer |
1057 |
retailerBrands.setIsUpdate(1);
|
|
|
1058 |
retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1059 |
retailerBrandsLimitRepository.persist(retailerBrands);
|
|
|
1060 |
|
|
|
1061 |
}
|
|
|
1062 |
retailerBrands = retailerBrandsLimitRepository.selectLimitByBrandAndFofoId(fofoId, brand);
|
|
|
1063 |
|
|
|
1064 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = new HashMap<>();
|
|
|
1065 |
|
|
|
1066 |
retailerBrandsLimitMap.put(retailerBrands.getPartnerId(), retailerBrands);
|
|
|
1067 |
|
|
|
1068 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brand);
|
|
|
1069 |
|
|
|
1070 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
|
|
1071 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
1072 |
model.addAttribute("customRetailers", customRetailers);
|
| 28277 |
tejbeer |
1073 |
|
|
|
1074 |
model.addAttribute("brand", brand);
|
| 28272 |
tejbeer |
1075 |
return "brands-limit-row-mapping";
|
|
|
1076 |
|
|
|
1077 |
}
|
|
|
1078 |
|
|
|
1079 |
@RequestMapping(value = "/getRetailerBrandslimitMapping", method = RequestMethod.GET)
|
|
|
1080 |
public String getRetailerBrandslimit(HttpServletRequest request,
|
| 30426 |
tejbeer |
1081 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
| 28272 |
tejbeer |
1082 |
throws Exception {
|
|
|
1083 |
|
|
|
1084 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
| 32751 |
amit.gupta |
1085 |
List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrand(brand);
|
| 28283 |
tejbeer |
1086 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
|
|
|
1087 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 28272 |
tejbeer |
1088 |
|
|
|
1089 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
1090 |
model.addAttribute("brand", brand);
|
| 28283 |
tejbeer |
1091 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
| 28272 |
tejbeer |
1092 |
|
|
|
1093 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brand);
|
|
|
1094 |
|
|
|
1095 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
1096 |
|
|
|
1097 |
return "brands-limit-mapping";
|
|
|
1098 |
|
|
|
1099 |
}
|
| 30426 |
tejbeer |
1100 |
|
| 28272 |
tejbeer |
1101 |
@RequestMapping(value = "/setBrandWiseLimit", method = RequestMethod.POST)
|
|
|
1102 |
public String brandwiseLimit(HttpServletRequest request,
|
| 30028 |
manish |
1103 |
@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
|
|
|
1104 |
@RequestParam(name = "limit", required = true, defaultValue = "") float limit, Model model)
|
| 28272 |
tejbeer |
1105 |
throws Exception {
|
|
|
1106 |
|
|
|
1107 |
LOGGER.info("limit" + limit);
|
|
|
1108 |
|
|
|
1109 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brands);
|
|
|
1110 |
|
| 32751 |
amit.gupta |
1111 |
List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrand(brands);
|
| 28272 |
tejbeer |
1112 |
|
|
|
1113 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
|
|
|
1114 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
1115 |
|
|
|
1116 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
|
|
1117 |
|
|
|
1118 |
if (brandLimit == null) {
|
|
|
1119 |
|
|
|
1120 |
brandLimit = new BrandLimit();
|
|
|
1121 |
brandLimit.setBrandLimit(limit);
|
|
|
1122 |
brandLimit.setBrandName(brands);
|
|
|
1123 |
brandLimit.setCreatedTimestamp(LocalDateTime.now());
|
|
|
1124 |
brandLimit.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1125 |
brandLimitRepository.persist(brandLimit);
|
|
|
1126 |
|
| 30028 |
manish |
1127 |
}
|
|
|
1128 |
|
|
|
1129 |
else {
|
| 28272 |
tejbeer |
1130 |
brandLimit.setBrandLimit(limit);
|
|
|
1131 |
|
|
|
1132 |
brandLimit.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1133 |
brandLimitRepository.persist(brandLimit);
|
|
|
1134 |
|
|
|
1135 |
}
|
|
|
1136 |
brandLimit = brandLimitRepository.setLimitByBrands(brands);
|
|
|
1137 |
|
|
|
1138 |
LOGGER.info("brandLimit" + brandLimit);
|
| 28277 |
tejbeer |
1139 |
model.addAttribute("brand", brands);
|
| 28272 |
tejbeer |
1140 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
1141 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
1142 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
|
|
1143 |
return "brands-limit-mapping";
|
|
|
1144 |
|
|
|
1145 |
}
|
| 28825 |
tejbeer |
1146 |
|
| 30028 |
manish |
1147 |
@RequestMapping(value = "/setBrandWiseStockLimit", method = RequestMethod.POST)
|
|
|
1148 |
public String setBrandWiseStockLimit(HttpServletRequest request,
|
|
|
1149 |
@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
|
|
|
1150 |
@RequestParam(name = "stockLimit", required = true, defaultValue = "") float stockLimit, Model model)
|
|
|
1151 |
throws Exception {
|
|
|
1152 |
|
|
|
1153 |
LOGGER.info("limit" + stockLimit);
|
|
|
1154 |
|
|
|
1155 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brands);
|
|
|
1156 |
|
| 32751 |
amit.gupta |
1157 |
List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrand(brands);
|
| 30028 |
manish |
1158 |
|
|
|
1159 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
|
|
|
1160 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
1161 |
|
|
|
1162 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
|
|
1163 |
|
|
|
1164 |
if (brandLimit == null) {
|
|
|
1165 |
|
|
|
1166 |
brandLimit = new BrandLimit();
|
|
|
1167 |
brandLimit.setBrandLimit(0);
|
|
|
1168 |
brandLimit.setBrandName(brands);
|
|
|
1169 |
brandLimit.setStockLimit(stockLimit);
|
|
|
1170 |
brandLimit.setCreatedTimestamp(LocalDateTime.now());
|
|
|
1171 |
brandLimit.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1172 |
brandLimitRepository.persist(brandLimit);
|
|
|
1173 |
|
|
|
1174 |
}
|
|
|
1175 |
|
|
|
1176 |
else {
|
|
|
1177 |
brandLimit.setStockLimit(stockLimit);
|
|
|
1178 |
|
|
|
1179 |
brandLimit.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
1180 |
brandLimitRepository.persist(brandLimit);
|
|
|
1181 |
|
|
|
1182 |
}
|
|
|
1183 |
brandLimit = brandLimitRepository.setLimitByBrands(brands);
|
|
|
1184 |
|
|
|
1185 |
model.addAttribute("brand", brands);
|
|
|
1186 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
1187 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
1188 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
|
|
1189 |
return "brands-limit-mapping";
|
|
|
1190 |
|
|
|
1191 |
}
|
|
|
1192 |
|
| 28381 |
tejbeer |
1193 |
@RequestMapping(value = "/setPartnerPincode", method = RequestMethod.POST)
|
|
|
1194 |
public String setPartnerPincode(HttpServletRequest request,
|
| 30426 |
tejbeer |
1195 |
@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode,
|
|
|
1196 |
@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
|
| 28825 |
tejbeer |
1197 |
throws Exception {
|
| 28272 |
tejbeer |
1198 |
|
| 28825 |
tejbeer |
1199 |
if (!pincode.equals("")) {
|
|
|
1200 |
PincodePartner pinPartner = new PincodePartner();
|
|
|
1201 |
pinPartner.setFofoId(fofoId);
|
|
|
1202 |
pinPartner.setPincode(pincode);
|
| 32751 |
amit.gupta |
1203 |
pincodePartnerRepository.perist(pinPartner);
|
| 28381 |
tejbeer |
1204 |
}
|
|
|
1205 |
|
| 32751 |
amit.gupta |
1206 |
List<PincodePartner> partnerPincodeList = pincodePartnerRepository.selectByPartnerId(fofoId);
|
| 28825 |
tejbeer |
1207 |
|
|
|
1208 |
LOGGER.info("partnerPincodeList" + partnerPincodeList);
|
|
|
1209 |
|
|
|
1210 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
| 28381 |
tejbeer |
1211 |
return "pincode-partner-index";
|
|
|
1212 |
|
|
|
1213 |
}
|
| 28825 |
tejbeer |
1214 |
|
| 28381 |
tejbeer |
1215 |
@RequestMapping(value = "/removePartnerPincode", method = RequestMethod.POST)
|
| 28825 |
tejbeer |
1216 |
public String removePartnerPincode(HttpServletRequest request, @RequestParam int id,
|
| 30426 |
tejbeer |
1217 |
@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
|
| 28825 |
tejbeer |
1218 |
throws Exception {
|
| 28381 |
tejbeer |
1219 |
|
| 32751 |
amit.gupta |
1220 |
pincodePartnerRepository.delete(id);
|
| 28381 |
tejbeer |
1221 |
|
| 32751 |
amit.gupta |
1222 |
List<PincodePartner> partnerPincodeList = pincodePartnerRepository.selectByPartnerId(fofoId);
|
| 28825 |
tejbeer |
1223 |
|
|
|
1224 |
LOGGER.info("partnerPincodeList" + partnerPincodeList);
|
|
|
1225 |
|
|
|
1226 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
|
|
1227 |
|
| 28381 |
tejbeer |
1228 |
return "pincode-partner-index";
|
|
|
1229 |
|
|
|
1230 |
}
|
| 28825 |
tejbeer |
1231 |
|
| 28381 |
tejbeer |
1232 |
@RequestMapping(value = "/removeSearchPincode", method = RequestMethod.POST)
|
| 28825 |
tejbeer |
1233 |
public String removeSearchPincode(HttpServletRequest request, @RequestParam int id,
|
| 30426 |
tejbeer |
1234 |
@RequestParam(name = "pin", required = true, defaultValue = "") String pin,
|
|
|
1235 |
@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
|
| 28825 |
tejbeer |
1236 |
throws Exception {
|
| 28381 |
tejbeer |
1237 |
|
| 32751 |
amit.gupta |
1238 |
pincodePartnerRepository.delete(id);
|
| 28381 |
tejbeer |
1239 |
|
| 32751 |
amit.gupta |
1240 |
List<PincodePartner> partnerPincodeList = pincodePartnerRepository.selectPartnersByPincode(pin);
|
| 28381 |
tejbeer |
1241 |
|
| 28825 |
tejbeer |
1242 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
|
|
1243 |
|
|
|
1244 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
|
|
1245 |
|
|
|
1246 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
|
|
1247 |
|
| 28381 |
tejbeer |
1248 |
return "search-pincode-partner";
|
|
|
1249 |
|
|
|
1250 |
}
|
| 28825 |
tejbeer |
1251 |
|
| 28381 |
tejbeer |
1252 |
@RequestMapping(value = "/searchPincodePartner", method = RequestMethod.GET)
|
|
|
1253 |
public String searchPincodePartner(HttpServletRequest request,
|
| 30426 |
tejbeer |
1254 |
@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode, Model model)
|
| 28825 |
tejbeer |
1255 |
throws Exception {
|
| 28381 |
tejbeer |
1256 |
|
| 32751 |
amit.gupta |
1257 |
List<PincodePartner> partnerPincodeList = pincodePartnerRepository.selectPartnersByPincode(pincode);
|
| 28825 |
tejbeer |
1258 |
|
| 28381 |
tejbeer |
1259 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
|
|
1260 |
|
|
|
1261 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 28825 |
tejbeer |
1262 |
|
| 28381 |
tejbeer |
1263 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
| 28825 |
tejbeer |
1264 |
|
| 28381 |
tejbeer |
1265 |
return "search-pincode-partner";
|
| 28825 |
tejbeer |
1266 |
|
| 28381 |
tejbeer |
1267 |
}
|
| 28825 |
tejbeer |
1268 |
|
| 28381 |
tejbeer |
1269 |
@RequestMapping(value = "/showPartnerPincode", method = RequestMethod.GET)
|
|
|
1270 |
public String showPartnerPincode(HttpServletRequest request,
|
| 30426 |
tejbeer |
1271 |
@RequestParam(name = "partnerId", required = true, defaultValue = "") int partnerId, Model model)
|
| 28825 |
tejbeer |
1272 |
throws Exception {
|
| 28381 |
tejbeer |
1273 |
|
| 32751 |
amit.gupta |
1274 |
List<PincodePartner> partnerPincodeList = pincodePartnerRepository.selectByPartnerId(partnerId);
|
| 28825 |
tejbeer |
1275 |
|
| 28381 |
tejbeer |
1276 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
| 28825 |
tejbeer |
1277 |
|
| 28381 |
tejbeer |
1278 |
return "pincode-partner-index";
|
| 28825 |
tejbeer |
1279 |
|
| 28381 |
tejbeer |
1280 |
}
|
| 28825 |
tejbeer |
1281 |
|
| 28381 |
tejbeer |
1282 |
@RequestMapping(value = "/getAllPartnerPincode", method = RequestMethod.GET)
|
| 28825 |
tejbeer |
1283 |
public String getAllPartnerPincode(HttpServletRequest request, Model model) throws Exception {
|
| 28381 |
tejbeer |
1284 |
return "add-partner-pincode";
|
|
|
1285 |
}
|
| 32629 |
amit.gupta |
1286 |
|
| 33814 |
ranu |
1287 |
@RequestMapping(value = "/alternateRetailerContacts", method = RequestMethod.GET)
|
|
|
1288 |
public String alternateRetailerContacts(HttpServletRequest request, Model model) throws Exception {
|
|
|
1289 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
1290 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 32667 |
raveendra. |
1291 |
|
| 33814 |
ranu |
1292 |
model.addAttribute("isAdmin", isAdmin);
|
|
|
1293 |
return "retailer-contacts";
|
|
|
1294 |
}
|
|
|
1295 |
|
|
|
1296 |
@RequestMapping(value = "/retailer-contact-list", method = RequestMethod.GET)
|
|
|
1297 |
public String getRetailerContactList(HttpServletRequest request, Model model, @RequestParam(defaultValue = "0") int fofoId)
|
|
|
1298 |
throws Exception {
|
|
|
1299 |
|
|
|
1300 |
List<RetailerContact> retailerContacts = retailerContactRepository.selectAllByRetailerId(fofoId);
|
|
|
1301 |
|
|
|
1302 |
model.addAttribute("retailerContacts", retailerContacts);
|
|
|
1303 |
|
|
|
1304 |
return "retailer-contact-list";
|
|
|
1305 |
|
|
|
1306 |
}
|
|
|
1307 |
|
|
|
1308 |
@RequestMapping(value = "/add-retailer-contact-list", method = RequestMethod.GET)
|
|
|
1309 |
public String updateRetailerContactList(HttpServletRequest request, Model model, @RequestParam(defaultValue = "0") int fofoId, @RequestParam String contactName, @RequestParam String contactNumber)
|
|
|
1310 |
throws Exception {
|
|
|
1311 |
|
|
|
1312 |
RetailerContact retailerContact = new RetailerContact();
|
|
|
1313 |
retailerContact.setFofoId(fofoId);
|
|
|
1314 |
retailerContact.setName(contactName);
|
|
|
1315 |
retailerContact.setMobile(contactNumber);
|
|
|
1316 |
retailerContact.setActive(true);
|
|
|
1317 |
retailerContact.setCreatedAt(LocalDateTime.now());
|
|
|
1318 |
retailerContactRepository.persist(retailerContact);
|
|
|
1319 |
|
|
|
1320 |
List<RetailerContact> retailerContacts = retailerContactRepository.selectAllByRetailerId(fofoId);
|
|
|
1321 |
|
|
|
1322 |
model.addAttribute("retailerContacts", retailerContacts);
|
|
|
1323 |
|
|
|
1324 |
return "retailer-contact-list";
|
|
|
1325 |
|
|
|
1326 |
}
|
|
|
1327 |
|
|
|
1328 |
@RequestMapping(value = "/update-contact-status", method = RequestMethod.GET)
|
|
|
1329 |
public String updateRetailerContactStatus(HttpServletRequest request, Model model, @RequestParam(defaultValue = "0") int fofoId, @RequestParam(defaultValue = "0") int contactId, @RequestParam boolean active)
|
|
|
1330 |
throws Exception {
|
|
|
1331 |
|
|
|
1332 |
RetailerContact retailerContact = retailerContactRepository.selectById(contactId);
|
|
|
1333 |
retailerContact.setActive(active);
|
|
|
1334 |
|
|
|
1335 |
List<RetailerContact> retailerContacts = retailerContactRepository.selectAllByRetailerId(fofoId);
|
|
|
1336 |
|
|
|
1337 |
model.addAttribute("retailerContacts", retailerContacts);
|
|
|
1338 |
|
|
|
1339 |
return "retailer-contact-list";
|
|
|
1340 |
|
|
|
1341 |
}
|
|
|
1342 |
|
|
|
1343 |
|
| 28272 |
tejbeer |
1344 |
}
|