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