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