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