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