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