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