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