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