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