| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.File;
|
3 |
import java.io.File;
|
| 4 |
import java.io.FileInputStream;
|
4 |
import java.io.FileInputStream;
|
| 5 |
import java.io.FileNotFoundException;
|
5 |
import java.io.FileNotFoundException;
|
| - |
|
6 |
import java.time.Instant;
|
| 6 |
import java.time.LocalDate;
|
7 |
import java.time.LocalDate;
|
| 7 |
import java.time.LocalDateTime;
|
8 |
import java.time.LocalDateTime;
|
| 8 |
import java.util.AbstractMap;
|
9 |
import java.util.AbstractMap;
|
| 9 |
import java.util.ArrayList;
|
10 |
import java.util.ArrayList;
|
| 10 |
import java.util.Arrays;
|
11 |
import java.util.Arrays;
|
| - |
|
12 |
import java.util.Date;
|
| 11 |
import java.util.HashMap;
|
13 |
import java.util.HashMap;
|
| 12 |
import java.util.List;
|
14 |
import java.util.List;
|
| 13 |
import java.util.Map;
|
15 |
import java.util.Map;
|
| 14 |
import java.util.Map.Entry;
|
- |
|
| 15 |
import java.util.Set;
|
16 |
import java.util.Set;
|
| 16 |
import java.util.stream.Collectors;
|
17 |
import java.util.stream.Collectors;
|
| 17 |
|
18 |
|
| 18 |
import javax.servlet.http.HttpServletRequest;
|
19 |
import javax.servlet.http.HttpServletRequest;
|
| 19 |
import javax.transaction.Transactional;
|
20 |
import javax.transaction.Transactional;
|
| Line 45... |
Line 46... |
| 45 |
import com.spice.profitmandi.common.model.PromoterDetailModel;
|
46 |
import com.spice.profitmandi.common.model.PromoterDetailModel;
|
| 46 |
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
|
47 |
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
|
| 47 |
import com.spice.profitmandi.common.util.Utils;
|
48 |
import com.spice.profitmandi.common.util.Utils;
|
| 48 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
49 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 49 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
50 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 50 |
import com.spice.profitmandi.dao.entity.cs.PartnerPosition;
|
- |
|
| 51 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
- |
|
| 52 |
import com.spice.profitmandi.dao.entity.dtr.BrandLimit;
|
51 |
import com.spice.profitmandi.dao.entity.dtr.BrandLimit;
|
| 53 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
52 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 54 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
53 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 55 |
import com.spice.profitmandi.dao.entity.dtr.RetailerBlockBrands;
|
54 |
import com.spice.profitmandi.dao.entity.dtr.RetailerBlockBrands;
|
| 56 |
import com.spice.profitmandi.dao.entity.dtr.RetailerBrandsLimit;
|
55 |
import com.spice.profitmandi.dao.entity.dtr.RetailerBrandsLimit;
|
| Line 60... |
Line 59... |
| 60 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
|
59 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
|
| 61 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
60 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
| 62 |
import com.spice.profitmandi.dao.entity.user.Location;
|
61 |
import com.spice.profitmandi.dao.entity.user.Location;
|
| 63 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
62 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
| 64 |
import com.spice.profitmandi.dao.entity.user.User;
|
63 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 65 |
import com.spice.profitmandi.dao.entity.warehouse.WarehouseInventoryItem;
|
- |
|
| 66 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
64 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 67 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
65 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 68 |
import com.spice.profitmandi.dao.repository.cs.RetailerBrandsLimitService;
|
66 |
import com.spice.profitmandi.dao.repository.cs.RetailerBrandsLimitService;
|
| 69 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
67 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
| 70 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
68 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| Line 421... |
Line 419... |
| 421 |
}
|
419 |
}
|
| 422 |
fofoStore.setActive(false);
|
420 |
fofoStore.setActive(false);
|
| 423 |
fofoStoreRepository.persist(fofoStore);
|
421 |
fofoStoreRepository.persist(fofoStore);
|
| 424 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
422 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
| 425 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
423 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 426 |
|
- |
|
| 427 |
return "response";
|
424 |
return "response";
|
| 428 |
|
- |
|
| 429 |
}
|
425 |
}
|
| - |
|
426 |
|
| - |
|
427 |
|
| - |
|
428 |
@PostMapping(value = "/activateStoreForever")
|
| - |
|
429 |
public String activateStoreForever(HttpServletRequest request,
|
| - |
|
430 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
| - |
|
431 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| - |
|
432 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
433 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com","manish.tiwari@smartdukaan.com")
|
| - |
|
434 |
.contains(loginDetails.getEmailId())) {
|
| - |
|
435 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
| - |
|
436 |
"You are not authorise to activate retailer");
|
| - |
|
437 |
}
|
| - |
|
438 |
fofoStore.setActive(true);
|
| - |
|
439 |
fofoStoreRepository.persist(fofoStore);
|
| - |
|
440 |
LOGGER.info("inserted into ActiveFofoStore successfully");
|
| - |
|
441 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
442 |
return "response";
|
| - |
|
443 |
}
|
| - |
|
444 |
|
| - |
|
445 |
@PostMapping(value = "/activateStoreTemporary")
|
| - |
|
446 |
public String activateStoreTemporary(HttpServletRequest request,
|
| - |
|
447 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
|
| - |
|
448 |
@RequestParam(name = "days", required = true ) int days,Model model) throws Exception {
|
| - |
|
449 |
|
| - |
|
450 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| - |
|
451 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
452 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com","manish.tiwari@smartdukaan.com")
|
| - |
|
453 |
.contains(loginDetails.getEmailId())) {
|
| - |
|
454 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
| - |
|
455 |
"You are not authorise to deactivate retailer");
|
| - |
|
456 |
}
|
| - |
|
457 |
|
| - |
|
458 |
LocalDateTime currentDate =LocalDate.now().atStartOfDay();
|
| - |
|
459 |
|
| - |
|
460 |
LocalDateTime EndDate = currentDate.plusDays(days);
|
| - |
|
461 |
fofoStore.setActiveTimeStamp(EndDate);
|
| - |
|
462 |
|
| - |
|
463 |
LOGGER.info("EndDate"+EndDate);
|
| - |
|
464 |
LOGGER.info("getActiveTimeStamp"+fofoStore.getActiveTimeStamp());
|
| - |
|
465 |
|
| - |
|
466 |
if( currentDate.isBefore(fofoStore.getActiveTimeStamp()))
|
| - |
|
467 |
{
|
| - |
|
468 |
|
| - |
|
469 |
fofoStore.setActive(true);
|
| - |
|
470 |
fofoStoreRepository.persist(fofoStore);
|
| - |
|
471 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
| - |
|
472 |
|
| - |
|
473 |
}
|
| - |
|
474 |
|
| - |
|
475 |
|
| - |
|
476 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| - |
|
477 |
return "response";
|
| - |
|
478 |
}
|
| - |
|
479 |
|
| - |
|
480 |
|
| 430 |
|
481 |
|
| 431 |
@GetMapping(value = "/getAllInactiveStores")
|
482 |
@GetMapping(value = "/getAllInactiveStores")
|
| 432 |
public String getInactiveStores(HttpServletRequest request, Model model) {
|
483 |
public String getInactiveStores(HttpServletRequest request, Model model) {
|
| 433 |
List<FofoStore> inActiveFofoStores = fofoStoreRepository.selectInActiveStore();
|
484 |
List<FofoStore> inActiveFofoStores = fofoStoreRepository.selectInActiveStore();
|
| 434 |
Map<Integer, CustomRetailer> customRetailers = retailerService
|
485 |
Map<Integer, CustomRetailer> customRetailers = retailerService
|