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