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