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