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