| 22981 |
ashik.ali |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23494 |
ashik.ali |
3 |
import java.io.File;
|
|
|
4 |
import java.io.FileInputStream;
|
|
|
5 |
import java.io.FileNotFoundException;
|
| 28710 |
amit.gupta |
6 |
import java.time.Instant;
|
| 24349 |
amit.gupta |
7 |
import java.time.LocalDate;
|
| 24159 |
tejbeer |
8 |
import java.time.LocalDateTime;
|
| 28272 |
tejbeer |
9 |
import java.util.AbstractMap;
|
| 24124 |
govind |
10 |
import java.util.ArrayList;
|
| 25276 |
amit.gupta |
11 |
import java.util.Arrays;
|
| 28710 |
amit.gupta |
12 |
import java.util.Date;
|
| 24349 |
amit.gupta |
13 |
import java.util.HashMap;
|
| 24124 |
govind |
14 |
import java.util.List;
|
| 22981 |
ashik.ali |
15 |
import java.util.Map;
|
| 24986 |
tejbeer |
16 |
import java.util.Set;
|
| 24159 |
tejbeer |
17 |
import java.util.stream.Collectors;
|
| 22981 |
ashik.ali |
18 |
|
|
|
19 |
import javax.servlet.http.HttpServletRequest;
|
| 25276 |
amit.gupta |
20 |
import javax.transaction.Transactional;
|
| 22981 |
ashik.ali |
21 |
|
| 24159 |
tejbeer |
22 |
import org.apache.logging.log4j.LogManager;
|
| 23955 |
govind |
23 |
import org.apache.logging.log4j.Logger;
|
| 24159 |
tejbeer |
24 |
import org.json.JSONObject;
|
| 22981 |
ashik.ali |
25 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 24159 |
tejbeer |
26 |
import org.springframework.beans.factory.annotation.Qualifier;
|
| 23494 |
ashik.ali |
27 |
import org.springframework.core.io.InputStreamResource;
|
|
|
28 |
import org.springframework.http.HttpHeaders;
|
|
|
29 |
import org.springframework.http.HttpStatus;
|
| 23330 |
ashik.ali |
30 |
import org.springframework.http.ResponseEntity;
|
| 22981 |
ashik.ali |
31 |
import org.springframework.stereotype.Controller;
|
|
|
32 |
import org.springframework.ui.Model;
|
| 24124 |
govind |
33 |
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
34 |
import org.springframework.web.bind.annotation.PostMapping;
|
| 23026 |
ashik.ali |
35 |
import org.springframework.web.bind.annotation.RequestBody;
|
| 22981 |
ashik.ali |
36 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
37 |
import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
38 |
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
39 |
|
| 23494 |
ashik.ali |
40 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 23955 |
govind |
41 |
import com.spice.profitmandi.common.enumuration.CounterSize;
|
| 28825 |
tejbeer |
42 |
import com.spice.profitmandi.common.enumuration.FofoType;
|
| 22981 |
ashik.ali |
43 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24123 |
tejbeer |
44 |
import com.spice.profitmandi.common.model.AddLocationModel;
|
| 24124 |
govind |
45 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 22981 |
ashik.ali |
46 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 24159 |
tejbeer |
47 |
import com.spice.profitmandi.common.model.PromoterDetailModel;
|
| 29267 |
manish |
48 |
import com.spice.profitmandi.common.model.SelectStorePartnerInfo;
|
|
|
49 |
import com.spice.profitmandi.common.model.SendMessageModel;
|
| 23026 |
ashik.ali |
50 |
import com.spice.profitmandi.common.model.UpdateRetailerRequest;
|
| 28024 |
tejbeer |
51 |
import com.spice.profitmandi.common.util.Utils;
|
| 23330 |
ashik.ali |
52 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 27231 |
tejbeer |
53 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 28272 |
tejbeer |
54 |
import com.spice.profitmandi.dao.entity.dtr.BrandLimit;
|
| 23494 |
ashik.ali |
55 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
|
|
56 |
import com.spice.profitmandi.dao.entity.dtr.Retailer;
|
| 28024 |
tejbeer |
57 |
import com.spice.profitmandi.dao.entity.dtr.RetailerBlockBrands;
|
| 28272 |
tejbeer |
58 |
import com.spice.profitmandi.dao.entity.dtr.RetailerBrandsLimit;
|
| 23494 |
ashik.ali |
59 |
import com.spice.profitmandi.dao.entity.dtr.Shop;
|
| 24124 |
govind |
60 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 28908 |
tejbeer |
61 |
import com.spice.profitmandi.dao.entity.fofo.PartnerOnBoardingPanel;
|
| 27797 |
tejbeer |
62 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
|
|
63 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTypeChange;
|
| 29267 |
manish |
64 |
import com.spice.profitmandi.dao.entity.fofo.PaymentOption;
|
| 28381 |
tejbeer |
65 |
import com.spice.profitmandi.dao.entity.fofo.PincodePartner;
|
| 24159 |
tejbeer |
66 |
import com.spice.profitmandi.dao.entity.user.Location;
|
|
|
67 |
import com.spice.profitmandi.dao.entity.user.Promoter;
|
| 24123 |
tejbeer |
68 |
import com.spice.profitmandi.dao.entity.user.User;
|
| 28825 |
tejbeer |
69 |
|
| 27231 |
tejbeer |
70 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
|
|
71 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 28272 |
tejbeer |
72 |
import com.spice.profitmandi.dao.repository.cs.RetailerBrandsLimitService;
|
|
|
73 |
import com.spice.profitmandi.dao.repository.dtr.BrandLimitRepository;
|
| 23494 |
ashik.ali |
74 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
| 24124 |
govind |
75 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24159 |
tejbeer |
76 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 28908 |
tejbeer |
77 |
import com.spice.profitmandi.dao.repository.dtr.PartnerOnBoardingPanelRepository;
|
| 28024 |
tejbeer |
78 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBlockBrandsRepository;
|
| 28272 |
tejbeer |
79 |
import com.spice.profitmandi.dao.repository.dtr.RetailerBrandsLimitRepository;
|
| 23494 |
ashik.ali |
80 |
import com.spice.profitmandi.dao.repository.dtr.RetailerRepository;
|
|
|
81 |
import com.spice.profitmandi.dao.repository.dtr.ShopRepository;
|
| 27797 |
tejbeer |
82 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeRepository;
|
|
|
83 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 28381 |
tejbeer |
84 |
import com.spice.profitmandi.dao.repository.fofo.PincodePartnerRepository;
|
| 24123 |
tejbeer |
85 |
import com.spice.profitmandi.dao.repository.user.LocationRepository;
|
| 24159 |
tejbeer |
86 |
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
|
| 24123 |
tejbeer |
87 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 24349 |
amit.gupta |
88 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 24159 |
tejbeer |
89 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 22981 |
ashik.ali |
90 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 28908 |
tejbeer |
91 |
import com.spice.profitmandi.service.user.StoreTimelineTatService;
|
| 25276 |
amit.gupta |
92 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
93 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24123 |
tejbeer |
94 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22981 |
ashik.ali |
95 |
|
|
|
96 |
@Controller
|
| 25277 |
amit.gupta |
97 |
@Transactional(rollbackOn = Throwable.class)
|
| 22981 |
ashik.ali |
98 |
public class RetailerController {
|
|
|
99 |
|
| 23568 |
govind |
100 |
private static final Logger LOGGER = LogManager.getLogger(RetailerController.class);
|
| 24124 |
govind |
101 |
|
| 22981 |
ashik.ali |
102 |
@Autowired
|
|
|
103 |
private RetailerService retailerService;
|
| 24124 |
govind |
104 |
|
| 23330 |
ashik.ali |
105 |
@Autowired
|
| 28832 |
tejbeer |
106 |
private RetailerRepository retailerRepository;
|
|
|
107 |
|
| 23494 |
ashik.ali |
108 |
@Autowired
|
| 28381 |
tejbeer |
109 |
private PincodePartnerRepository PincodePartnerRepository;
|
| 28832 |
tejbeer |
110 |
|
| 28381 |
tejbeer |
111 |
@Autowired
|
| 28272 |
tejbeer |
112 |
private BrandLimitRepository brandLimitRepository;
|
|
|
113 |
|
|
|
114 |
@Autowired
|
|
|
115 |
private RetailerBrandsLimitService retailerBrandsLimitService;
|
|
|
116 |
|
|
|
117 |
@Autowired
|
|
|
118 |
private RetailerBrandsLimitRepository retailerBrandsLimitRepository;
|
|
|
119 |
|
|
|
120 |
@Autowired
|
| 23494 |
ashik.ali |
121 |
private ShopRepository shopRepository;
|
| 24124 |
govind |
122 |
|
| 23494 |
ashik.ali |
123 |
@Autowired
|
| 28024 |
tejbeer |
124 |
private RetailerBlockBrandsRepository retailerBlockBrandsRepository;
|
|
|
125 |
|
|
|
126 |
@Autowired
|
| 24124 |
govind |
127 |
private FofoStoreRepository fofoStoreRepository;
|
|
|
128 |
|
|
|
129 |
@Autowired
|
| 23494 |
ashik.ali |
130 |
private DocumentRepository documentRepository;
|
| 24124 |
govind |
131 |
|
| 23494 |
ashik.ali |
132 |
@Autowired
|
| 25276 |
amit.gupta |
133 |
private CookiesProcessor cookiesProcessor;
|
|
|
134 |
|
|
|
135 |
@Autowired
|
| 24159 |
tejbeer |
136 |
@Qualifier("userUserRepository")
|
| 24123 |
tejbeer |
137 |
private UserRepository userRepository;
|
| 24124 |
govind |
138 |
|
| 24123 |
tejbeer |
139 |
@Autowired
|
| 27231 |
tejbeer |
140 |
private AuthRepository authRepository;
|
|
|
141 |
|
|
|
142 |
@Autowired
|
|
|
143 |
private CsService csService;
|
|
|
144 |
|
|
|
145 |
@Autowired
|
| 24123 |
tejbeer |
146 |
private LocationRepository locationRepository;
|
| 24124 |
govind |
147 |
|
| 24123 |
tejbeer |
148 |
@Autowired
|
| 23330 |
ashik.ali |
149 |
private ResponseSender<?> responseSender;
|
| 24124 |
govind |
150 |
|
| 24123 |
tejbeer |
151 |
@Autowired
|
|
|
152 |
private MVCResponseSender mvcResponseSender;
|
| 24124 |
govind |
153 |
|
| 24159 |
tejbeer |
154 |
@Autowired
|
|
|
155 |
private InventoryService inventoryService;
|
|
|
156 |
|
|
|
157 |
@Autowired
|
|
|
158 |
private PromoterRepository promoterRepository;
|
|
|
159 |
|
|
|
160 |
@Autowired
|
| 24349 |
amit.gupta |
161 |
private PartnerInvestmentService partnerInvestmentService;
|
|
|
162 |
|
|
|
163 |
@Autowired
|
| 24159 |
tejbeer |
164 |
private Mongo mongoClient;
|
|
|
165 |
|
| 27797 |
tejbeer |
166 |
@Autowired
|
|
|
167 |
private PartnerTypeChangeService partnerTypeChangeService;
|
|
|
168 |
|
|
|
169 |
@Autowired
|
|
|
170 |
private PartnerTypeChangeRepository partnerTypeChangeRepository;
|
|
|
171 |
|
| 28908 |
tejbeer |
172 |
@Autowired
|
|
|
173 |
PartnerOnBoardingPanelRepository partnerOnBoardingPanelRepository;
|
|
|
174 |
|
|
|
175 |
@Autowired
|
|
|
176 |
private StoreTimelineTatService storeTimelineTatService;
|
|
|
177 |
|
| 23784 |
ashik.ali |
178 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.GET)
|
| 24124 |
govind |
179 |
public String retailerInfoByEmailIdOrMobileNumber(HttpServletRequest request,
|
|
|
180 |
@RequestParam(name = ProfitMandiConstants.EMAIL_ID_OR_MOBILE_NUMBER) String emailIdOrMobileNumber,
|
|
|
181 |
Model model) throws ProfitMandiBusinessException {
|
|
|
182 |
LOGGER.info("Request Received at url {} with emailIdOrMobileNumber {}", request.getRequestURI(),
|
|
|
183 |
emailIdOrMobileNumber);
|
| 28071 |
tejbeer |
184 |
|
|
|
185 |
Map<String, Object> map = retailerService.getByEmailIdOrMobileNumber(emailIdOrMobileNumber);
|
|
|
186 |
|
| 26771 |
amit.gupta |
187 |
model.addAllAttributes(map);
|
| 28071 |
tejbeer |
188 |
|
| 23955 |
govind |
189 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 26209 |
tejbeer |
190 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
| 28825 |
tejbeer |
191 |
|
| 26209 |
tejbeer |
192 |
LOGGER.info("warehouseMap", warehouseMap);
|
|
|
193 |
model.addAttribute("warehouses", warehouseMap);
|
| 28825 |
tejbeer |
194 |
model.addAttribute("fofoTypes", FofoType.values());
|
| 26771 |
amit.gupta |
195 |
if (map.containsKey("retailer")) {
|
|
|
196 |
Retailer retailer = (Retailer) map.get("retailer");
|
|
|
197 |
User user = userRepository.selectById(retailer.getId());
|
|
|
198 |
if (user.getLocation() != null) {
|
|
|
199 |
Location location = locationRepository.selectById(user.getLocation());
|
|
|
200 |
model.addAttribute("locationdetail", location);
|
|
|
201 |
LOGGER.info("location" + location);
|
|
|
202 |
}
|
|
|
203 |
}
|
| 22981 |
ashik.ali |
204 |
return "retailer-details";
|
|
|
205 |
}
|
| 24124 |
govind |
206 |
|
| 23026 |
ashik.ali |
207 |
@RequestMapping(value = "/retailerDetails", method = RequestMethod.PUT)
|
| 24124 |
govind |
208 |
public String updateRetailerDetails(HttpServletRequest request,
|
|
|
209 |
@RequestBody UpdateRetailerRequest updateRetailerRequest, Model model) throws ProfitMandiBusinessException {
|
| 23026 |
ashik.ali |
210 |
LOGGER.info("Request Received at url {} with body {}", request.getRequestURI(), updateRetailerRequest);
|
|
|
211 |
Map<String, Object> map = retailerService.updateRetailerDetails(updateRetailerRequest);
|
| 28071 |
tejbeer |
212 |
|
| 23026 |
ashik.ali |
213 |
model.addAllAttributes(map);
|
| 23955 |
govind |
214 |
model.addAttribute("counterSizes", CounterSize.values());
|
| 26209 |
tejbeer |
215 |
Map<Integer, String> warehouseMap = ProfitMandiConstants.WAREHOUSE_MAP;
|
|
|
216 |
LOGGER.info("warehouseMap", warehouseMap);
|
|
|
217 |
model.addAttribute("warehouses", warehouseMap);
|
| 28832 |
tejbeer |
218 |
model.addAttribute("fofoTypes", FofoType.values());
|
| 23026 |
ashik.ali |
219 |
return "retailer-details";
|
|
|
220 |
}
|
| 22981 |
ashik.ali |
221 |
|
|
|
222 |
@RequestMapping(value = "/retailerInfo", method = RequestMethod.GET)
|
| 24124 |
govind |
223 |
public String retailerInfo(HttpServletRequest request) throws Exception {
|
| 22981 |
ashik.ali |
224 |
return "retailer-info";
|
|
|
225 |
}
|
| 24124 |
govind |
226 |
|
| 23330 |
ashik.ali |
227 |
@RequestMapping(value = "/district/all/stateName", method = RequestMethod.GET)
|
| 24124 |
govind |
228 |
public ResponseEntity<?> getAllDistrict(@RequestParam(name = "stateName") String stateName) {
|
| 23330 |
ashik.ali |
229 |
return responseSender.ok(retailerService.getAllDistrictMaster(stateName));
|
|
|
230 |
}
|
| 24124 |
govind |
231 |
|
| 23494 |
ashik.ali |
232 |
@RequestMapping(value = "/retailerDocument/documentId", method = RequestMethod.GET)
|
| 24124 |
govind |
233 |
public ResponseEntity<?> retailerDocumentById(HttpServletRequest request,
|
|
|
234 |
@RequestParam(name = ProfitMandiConstants.DOCUMENT_ID) int documentId,
|
|
|
235 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
|
| 23494 |
ashik.ali |
236 |
Document document = documentRepository.selectById(documentId);
|
| 23499 |
ashik.ali |
237 |
Retailer retailer = retailerRepository.selectById(retailerId);
|
| 24124 |
govind |
238 |
|
|
|
239 |
if (retailer.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
240 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
|
|
|
241 |
}
|
| 24124 |
govind |
242 |
if (retailer.getDocumentId() != documentId) {
|
| 23494 |
ashik.ali |
243 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, documentId, "RTLR_1014");
|
|
|
244 |
}
|
|
|
245 |
return responseSender.ok(document);
|
|
|
246 |
}
|
| 24124 |
govind |
247 |
|
| 23494 |
ashik.ali |
248 |
@RequestMapping(value = "/retailerDocument/download", method = RequestMethod.GET)
|
| 24124 |
govind |
249 |
public ResponseEntity<?> downloadRetailerDocument(HttpServletRequest request,
|
|
|
250 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
|
|
|
251 |
throws ProfitMandiBusinessException {
|
|
|
252 |
|
| 23499 |
ashik.ali |
253 |
Retailer retailer = retailerRepository.selectById(retailerId);
|
| 24124 |
govind |
254 |
|
|
|
255 |
if (retailer.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
256 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, retailer.getId(), "RTLR_1012");
|
|
|
257 |
}
|
| 24124 |
govind |
258 |
|
| 23494 |
ashik.ali |
259 |
Document document = documentRepository.selectById(retailer.getDocumentId());
|
| 24124 |
govind |
260 |
|
| 23494 |
ashik.ali |
261 |
FileInputStream file = null;
|
|
|
262 |
try {
|
|
|
263 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
264 |
} catch (FileNotFoundException e) {
|
|
|
265 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
266 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
267 |
}
|
| 24159 |
tejbeer |
268 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
269 |
// ByteArrayOutputStream();
|
| 24124 |
govind |
270 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
271 |
|
|
|
272 |
final HttpHeaders headers = new HttpHeaders();
|
| 23494 |
ashik.ali |
273 |
String contentType = "";
|
| 24124 |
govind |
274 |
if (document.getContentType() == ContentType.JPEG) {
|
| 23494 |
ashik.ali |
275 |
contentType = "image/jpeg";
|
| 24124 |
govind |
276 |
} else if (document.getContentType() == ContentType.PNG) {
|
| 23494 |
ashik.ali |
277 |
contentType = "image/png";
|
| 24124 |
govind |
278 |
} else if (document.getContentType() == ContentType.PDF) {
|
| 23494 |
ashik.ali |
279 |
contentType = "application/pdf";
|
|
|
280 |
}
|
| 24124 |
govind |
281 |
headers.set("Content-Type", contentType);
|
|
|
282 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
283 |
headers.setContentLength(document.getSize());
|
|
|
284 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
285 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
286 |
|
| 24159 |
tejbeer |
287 |
// return
|
|
|
288 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 23494 |
ashik.ali |
289 |
}
|
| 24124 |
govind |
290 |
|
| 23494 |
ashik.ali |
291 |
@RequestMapping(value = "/retailerShopDocument/shopId", method = RequestMethod.GET)
|
| 24124 |
govind |
292 |
public ResponseEntity<?> retailerShopDocumentById(HttpServletRequest request,
|
|
|
293 |
@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
|
|
|
294 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId) throws ProfitMandiBusinessException {
|
| 23494 |
ashik.ali |
295 |
Shop shop = shopRepository.selectById(shopId);
|
| 24124 |
govind |
296 |
|
|
|
297 |
if (shop.getRetailerId() != retailerId) {
|
| 23494 |
ashik.ali |
298 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
|
|
|
299 |
}
|
| 24124 |
govind |
300 |
|
|
|
301 |
if (shop.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
302 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
|
|
|
303 |
}
|
| 24124 |
govind |
304 |
|
| 23494 |
ashik.ali |
305 |
Document document = documentRepository.selectById(shop.getDocumentId());
|
|
|
306 |
return responseSender.ok(document);
|
|
|
307 |
}
|
| 24124 |
govind |
308 |
|
| 23494 |
ashik.ali |
309 |
@RequestMapping(value = "/retailerShopDocument/download", method = RequestMethod.GET)
|
| 24124 |
govind |
310 |
public ResponseEntity<?> downloadRetailerShopDocument(HttpServletRequest request,
|
|
|
311 |
@RequestParam(name = ProfitMandiConstants.SHOP_ID) int shopId,
|
|
|
312 |
@RequestParam(name = ProfitMandiConstants.RETAILER_ID) int retailerId, Model model)
|
|
|
313 |
throws ProfitMandiBusinessException {
|
|
|
314 |
|
| 23494 |
ashik.ali |
315 |
Shop shop = shopRepository.selectById(shopId);
|
| 24124 |
govind |
316 |
|
|
|
317 |
if (shop.getRetailerId() != retailerId) {
|
| 23494 |
ashik.ali |
318 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.SHOP_ID, shop.getId(), "SHP_1004");
|
|
|
319 |
}
|
| 24124 |
govind |
320 |
|
|
|
321 |
if (shop.getDocumentId() == null) {
|
| 23494 |
ashik.ali |
322 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.RETAILER_ID, shop.getId(), "SHP_1005");
|
|
|
323 |
}
|
| 24124 |
govind |
324 |
|
| 23494 |
ashik.ali |
325 |
Document document = documentRepository.selectById(shop.getDocumentId());
|
| 24124 |
govind |
326 |
|
| 23494 |
ashik.ali |
327 |
FileInputStream file = null;
|
|
|
328 |
try {
|
|
|
329 |
file = new FileInputStream(document.getPath() + File.separator + document.getName());
|
|
|
330 |
} catch (FileNotFoundException e) {
|
|
|
331 |
LOGGER.error("Retailer Document file not found : ", e);
|
|
|
332 |
throw new ProfitMandiBusinessException(ProfitMandiConstants.DOCUMENT_ID, document.getId(), "RTLR_1013");
|
|
|
333 |
}
|
| 24159 |
tejbeer |
334 |
// ByteArrayOutputStream byteArrayOutputStream = new
|
|
|
335 |
// ByteArrayOutputStream();
|
| 24124 |
govind |
336 |
// ExcelUtils.writeSchemeModels(schemeModels, byteArrayOutputStream);
|
|
|
337 |
|
|
|
338 |
final HttpHeaders headers = new HttpHeaders();
|
| 23494 |
ashik.ali |
339 |
String contentType = "";
|
| 24124 |
govind |
340 |
if (document.getContentType() == ContentType.JPEG) {
|
| 23494 |
ashik.ali |
341 |
contentType = "image/jpeg";
|
| 24124 |
govind |
342 |
} else if (document.getContentType() == ContentType.PNG) {
|
| 23494 |
ashik.ali |
343 |
contentType = "image/png";
|
| 24124 |
govind |
344 |
} else if (document.getContentType() == ContentType.PDF) {
|
| 23494 |
ashik.ali |
345 |
contentType = "application/pdf";
|
|
|
346 |
}
|
| 24124 |
govind |
347 |
headers.set("Content-Type", contentType);
|
|
|
348 |
headers.set("Content-disposition", "inline; filename=" + document.getName());
|
|
|
349 |
headers.setContentLength(document.getSize());
|
|
|
350 |
final InputStreamResource inputStreamResource = new InputStreamResource(file);
|
|
|
351 |
return new ResponseEntity<InputStreamResource>(inputStreamResource, headers, HttpStatus.OK);
|
|
|
352 |
|
| 24159 |
tejbeer |
353 |
// return
|
|
|
354 |
// responseSender.ok(ResponseCodeHolder.getMessage("ITM_AGNG_OK_1000"));
|
| 23494 |
ashik.ali |
355 |
}
|
| 29267 |
manish |
356 |
|
|
|
357 |
@GetMapping(value = "/getstore")
|
|
|
358 |
public String getstore(HttpServletRequest request, Model model) {
|
|
|
359 |
|
|
|
360 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
361 |
.collect(Collectors.toList());
|
|
|
362 |
;
|
|
|
363 |
Map<Integer, CustomRetailer> fofoIdsAndCustomRetailer = retailerService.getFofoRetailers(fofoIds);
|
|
|
364 |
LOGGER.info("fofoIds" + fofoIds);
|
|
|
365 |
model.addAttribute("fofoIdsAndCustomRetailer", fofoIdsAndCustomRetailer);
|
|
|
366 |
LOGGER.info("fofoIdsAndCustomRetailer" + fofoIdsAndCustomRetailer);
|
|
|
367 |
model.addAttribute("fofoIds", fofoIds);
|
| 24124 |
govind |
368 |
|
| 29267 |
manish |
369 |
|
|
|
370 |
return "store";
|
|
|
371 |
|
|
|
372 |
}
|
|
|
373 |
@RequestMapping(value = "/getPartnerinfo")
|
|
|
374 |
public String getPartnerinfo(HttpServletRequest request,
|
|
|
375 |
@RequestBody SelectStorePartnerInfo selectStorePartnerInfo,Model model) throws ProfitMandiBusinessException {
|
|
|
376 |
|
|
|
377 |
LOGGER.info("selectStorePartnerInfo" + selectStorePartnerInfo.getUserIds());
|
|
|
378 |
List<FofoStore> fofoStores = fofoStoreRepository.selectByRetailerIds(selectStorePartnerInfo.getUserIds());
|
|
|
379 |
LOGGER.info("fofoStoresInfo" + fofoStores);
|
|
|
380 |
Map<Integer, Boolean> investments = new HashMap<>();
|
|
|
381 |
|
|
|
382 |
for (FofoStore fofoStore : fofoStores) {
|
|
|
383 |
boolean isOk = false;
|
|
|
384 |
if (fofoStore.getGraceDate() != null && fofoStore.getGraceDate().isAfter(LocalDate.now())) {
|
|
|
385 |
isOk = true;
|
|
|
386 |
} else {
|
|
|
387 |
try {
|
|
|
388 |
isOk = partnerInvestmentService.isInvestmentOk(fofoStore.getId(), 10,
|
|
|
389 |
ProfitMandiConstants.CUTOFF_INVESTMENT);
|
|
|
390 |
if (fofoStore.getGraceCount() > 0) {
|
|
|
391 |
fofoStore.setGraceDate(null);
|
|
|
392 |
fofoStore.setGraceCount(0);
|
|
|
393 |
fofoStoreRepository.persist(fofoStore);
|
|
|
394 |
}
|
|
|
395 |
} catch (ProfitMandiBusinessException e) {
|
|
|
396 |
}
|
|
|
397 |
}
|
|
|
398 |
investments.put(fofoStore.getId(), isOk);
|
|
|
399 |
}
|
|
|
400 |
|
|
|
401 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(false);
|
|
|
402 |
model.addAttribute("fofoStores", fofoStores);
|
|
|
403 |
model.addAttribute("investments", investments);
|
|
|
404 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
405 |
|
|
|
406 |
return "store-investment";
|
|
|
407 |
|
|
|
408 |
}
|
|
|
409 |
|
|
|
410 |
|
| 24124 |
govind |
411 |
@GetMapping(value = "/getAllStores")
|
|
|
412 |
public String getAllStores(HttpServletRequest request, Model model) {
|
|
|
413 |
|
| 25276 |
amit.gupta |
414 |
List<FofoStore> fofoStores = fofoStoreRepository.selectAll().stream().filter(x -> x.isActive())
|
|
|
415 |
.collect(Collectors.toList());
|
| 24349 |
amit.gupta |
416 |
Map<Integer, Boolean> investments = new HashMap<>();
|
| 24124 |
govind |
417 |
|
| 24349 |
amit.gupta |
418 |
for (FofoStore fofoStore : fofoStores) {
|
|
|
419 |
boolean isOk = false;
|
|
|
420 |
if (fofoStore.getGraceDate() != null && fofoStore.getGraceDate().isAfter(LocalDate.now())) {
|
|
|
421 |
isOk = true;
|
|
|
422 |
} else {
|
|
|
423 |
try {
|
| 25276 |
amit.gupta |
424 |
isOk = partnerInvestmentService.isInvestmentOk(fofoStore.getId(), 10,
|
|
|
425 |
ProfitMandiConstants.CUTOFF_INVESTMENT);
|
|
|
426 |
if (fofoStore.getGraceCount() > 0) {
|
| 24349 |
amit.gupta |
427 |
fofoStore.setGraceDate(null);
|
|
|
428 |
fofoStore.setGraceCount(0);
|
|
|
429 |
fofoStoreRepository.persist(fofoStore);
|
|
|
430 |
}
|
|
|
431 |
} catch (ProfitMandiBusinessException e) {
|
|
|
432 |
}
|
|
|
433 |
}
|
|
|
434 |
investments.put(fofoStore.getId(), isOk);
|
|
|
435 |
}
|
| 24124 |
govind |
436 |
|
| 26963 |
amit.gupta |
437 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(false);
|
| 24124 |
govind |
438 |
model.addAttribute("fofoStores", fofoStores);
|
| 24349 |
amit.gupta |
439 |
model.addAttribute("investments", investments);
|
| 24124 |
govind |
440 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
441 |
|
| 29267 |
manish |
442 |
return "store-investment";
|
| 24124 |
govind |
443 |
|
|
|
444 |
}
|
|
|
445 |
|
| 27797 |
tejbeer |
446 |
@GetMapping(value = "/getPartnerCategory")
|
|
|
447 |
public String getPartnerCategory(HttpServletRequest request, @RequestParam int fofoId, Model model) {
|
|
|
448 |
|
|
|
449 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
|
|
450 |
List<PartnerType> partnerTypes = partnerType.nextPartnerTypes();
|
|
|
451 |
LOGGER.info("partnerType" + partnerTypes);
|
|
|
452 |
model.addAttribute("partnerTypes", partnerTypes);
|
|
|
453 |
model.addAttribute("fofoId", fofoId);
|
|
|
454 |
return "partner-category";
|
|
|
455 |
}
|
|
|
456 |
|
|
|
457 |
@PostMapping(value = "/updatePartnerCategory")
|
|
|
458 |
public String updatePartnerCategory(HttpServletRequest request, @RequestParam(name = "fofoId") int fofoId,
|
|
|
459 |
@RequestParam(name = "partnerType") PartnerType partnerType, Model model) throws Exception {
|
|
|
460 |
|
|
|
461 |
PartnerTypeChange ptc = new PartnerTypeChange();
|
|
|
462 |
ptc.setFofoId(fofoId);
|
|
|
463 |
ptc.setPartnerType(partnerType);
|
|
|
464 |
ptc.setCreateTimestamp(LocalDate.now().atStartOfDay().plusDays(1));
|
|
|
465 |
partnerTypeChangeRepository.persist(ptc);
|
|
|
466 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
467 |
|
|
|
468 |
return "response";
|
|
|
469 |
}
|
|
|
470 |
|
| 24349 |
amit.gupta |
471 |
@GetMapping(value = "/partners")
|
|
|
472 |
public String getStoreName(HttpServletRequest request, Model model, @RequestParam String query) throws Exception {
|
|
|
473 |
model.addAttribute("response", mvcResponseSender
|
| 26963 |
amit.gupta |
474 |
.createResponseString(retailerService.getFofoRetailers(false).values().stream().filter(x -> {
|
| 24349 |
amit.gupta |
475 |
return x.getDisplayName().toLowerCase().matches(".*?" + query.toLowerCase() + ".*?");
|
|
|
476 |
}).collect(Collectors.toList())));
|
|
|
477 |
return "response";
|
|
|
478 |
}
|
|
|
479 |
|
| 24124 |
govind |
480 |
@PostMapping(value = "/deactivateStore")
|
|
|
481 |
public String deActivateStore(HttpServletRequest request,
|
|
|
482 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
483 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 25276 |
amit.gupta |
484 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 27231 |
tejbeer |
485 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com")
|
| 26131 |
tejbeer |
486 |
.contains(loginDetails.getEmailId())) {
|
|
|
487 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
488 |
"You are not authorise to deactivate retailer");
|
| 25276 |
amit.gupta |
489 |
}
|
| 24843 |
govind |
490 |
fofoStore.setActive(false);
|
|
|
491 |
fofoStoreRepository.persist(fofoStore);
|
| 24124 |
govind |
492 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
|
|
493 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
494 |
return "response";
|
|
|
495 |
}
|
| 28825 |
tejbeer |
496 |
|
| 28710 |
amit.gupta |
497 |
@PostMapping(value = "/activateStoreForever")
|
|
|
498 |
public String activateStoreForever(HttpServletRequest request,
|
|
|
499 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
500 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
501 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 28825 |
tejbeer |
502 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
|
|
|
503 |
"manish.tiwari@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
| 28710 |
amit.gupta |
504 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
505 |
"You are not authorise to activate retailer");
|
|
|
506 |
}
|
|
|
507 |
fofoStore.setActive(true);
|
|
|
508 |
fofoStoreRepository.persist(fofoStore);
|
|
|
509 |
LOGGER.info("inserted into ActiveFofoStore successfully");
|
|
|
510 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
511 |
return "response";
|
|
|
512 |
}
|
| 28825 |
tejbeer |
513 |
|
| 28710 |
amit.gupta |
514 |
@PostMapping(value = "/activateStoreTemporary")
|
|
|
515 |
public String activateStoreTemporary(HttpServletRequest request,
|
|
|
516 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId,
|
| 28825 |
tejbeer |
517 |
@RequestParam(name = "days", required = true) int days, Model model) throws Exception {
|
|
|
518 |
|
| 28710 |
amit.gupta |
519 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
|
|
520 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 28825 |
tejbeer |
521 |
if (!Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "amit.gupta@smartdukaan.com",
|
|
|
522 |
"manish.tiwari@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
| 28710 |
amit.gupta |
523 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
524 |
"You are not authorise to deactivate retailer");
|
|
|
525 |
}
|
| 28825 |
tejbeer |
526 |
|
|
|
527 |
LocalDateTime currentDate = LocalDate.now().atStartOfDay();
|
|
|
528 |
|
| 28710 |
amit.gupta |
529 |
LocalDateTime EndDate = currentDate.plusDays(days);
|
|
|
530 |
fofoStore.setActiveTimeStamp(EndDate);
|
| 28825 |
tejbeer |
531 |
|
|
|
532 |
LOGGER.info("EndDate" + EndDate);
|
|
|
533 |
LOGGER.info("getActiveTimeStamp" + fofoStore.getActiveTimeStamp());
|
|
|
534 |
|
|
|
535 |
if (currentDate.isBefore(fofoStore.getActiveTimeStamp())) {
|
|
|
536 |
|
|
|
537 |
fofoStore.setActive(true);
|
|
|
538 |
fofoStoreRepository.persist(fofoStore);
|
|
|
539 |
LOGGER.info("inserted into InActiveFofoStore successfully");
|
|
|
540 |
|
| 28710 |
amit.gupta |
541 |
}
|
| 28825 |
tejbeer |
542 |
|
| 28710 |
amit.gupta |
543 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
544 |
return "response";
|
|
|
545 |
}
|
| 25276 |
amit.gupta |
546 |
|
|
|
547 |
@GetMapping(value = "/getAllInactiveStores")
|
|
|
548 |
public String getInactiveStores(HttpServletRequest request, Model model) {
|
|
|
549 |
List<FofoStore> inActiveFofoStores = fofoStoreRepository.selectInActiveStore();
|
|
|
550 |
Map<Integer, CustomRetailer> customRetailers = retailerService
|
|
|
551 |
.getFofoRetailers(inActiveFofoStores.stream().map(x -> x.getId()).collect(Collectors.toList()));
|
| 24680 |
govind |
552 |
model.addAttribute("inActiveFofoStores", inActiveFofoStores);
|
|
|
553 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
554 |
return "inactive-stores";
|
|
|
555 |
}
|
| 25276 |
amit.gupta |
556 |
|
|
|
557 |
// Extend billing for 2 days
|
| 24349 |
amit.gupta |
558 |
@PostMapping(value = "/extendBilling")
|
|
|
559 |
public String extendBilling(HttpServletRequest request,
|
|
|
560 |
@RequestParam(name = ProfitMandiConstants.FOFO_ID) int fofoId, Model model) throws Exception {
|
|
|
561 |
FofoStore fofoStore = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 25276 |
amit.gupta |
562 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 27231 |
tejbeer |
563 |
if (Arrays.asList("kamini.sharma@smartdukaan.com", "tarun.verma@smartdukaan.com", "prakash.rai@smartdukaan.com",
|
|
|
564 |
"amit.gupta@smartdukaan.com").contains(loginDetails.getEmailId())) {
|
| 25276 |
amit.gupta |
565 |
fofoStore.setGraceDate(LocalDate.now().plusDays(2));
|
|
|
566 |
fofoStore.setGraceCount(fofoStore.getGraceCount() + 1);
|
|
|
567 |
fofoStoreRepository.persist(fofoStore);
|
|
|
568 |
model.addAttribute("response", mvcResponseSender.createResponseString(fofoStore.getGraceCount()));
|
|
|
569 |
} else {
|
| 26131 |
tejbeer |
570 |
throw new ProfitMandiBusinessException("Access Denied", "Unauthorised Access",
|
|
|
571 |
"You are not authorise to extend billing");
|
| 25276 |
amit.gupta |
572 |
}
|
| 24349 |
amit.gupta |
573 |
return "response";
|
| 25276 |
amit.gupta |
574 |
|
| 24124 |
govind |
575 |
}
|
|
|
576 |
|
| 24159 |
tejbeer |
577 |
@RequestMapping(value = "/getPromoterInfo", method = RequestMethod.GET)
|
|
|
578 |
public String getPromoterInfo(HttpServletRequest request,
|
|
|
579 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 27489 |
tejbeer |
580 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
581 |
@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
|
|
|
582 |
throws Exception {
|
| 24159 |
tejbeer |
583 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
584 |
List<Promoter> promoterInfo = null;
|
|
|
585 |
|
|
|
586 |
long size = 0;
|
| 27489 |
tejbeer |
587 |
|
| 24159 |
tejbeer |
588 |
List<Integer> fofoIds = fofoStoreRepository.selectAll().stream().map(x -> x.getId())
|
|
|
589 |
.collect(Collectors.toList());
|
|
|
590 |
Map<Integer, CustomRetailer> customRetailersMap = retailerService.getFofoRetailers(fofoIds);
|
|
|
591 |
String customRetailers = JSONObject.valueToString(customRetailersMap.values());
|
| 24986 |
tejbeer |
592 |
Set<String> brands = inventoryService.getAllTagListingBrands(ProfitMandiConstants.MOBILE_CATEGORY_ID);
|
|
|
593 |
brands.add("Airtel");
|
|
|
594 |
brands.add("Vodafone");
|
|
|
595 |
brands.add("Idea");
|
| 25276 |
amit.gupta |
596 |
LOGGER.info("brands" + brands);
|
| 24159 |
tejbeer |
597 |
model.addAttribute("customRetailers", customRetailers);
|
| 25276 |
amit.gupta |
598 |
model.addAttribute("brands", brands);
|
| 24159 |
tejbeer |
599 |
|
| 27489 |
tejbeer |
600 |
if (fofoId != 0) {
|
|
|
601 |
promoterInfo = promoterRepository.selectAllPromoterByFofoId(fofoId, offset, limit);
|
| 24159 |
tejbeer |
602 |
|
| 27489 |
tejbeer |
603 |
size = promoterRepository.selectPromoterCount(fofoId);
|
|
|
604 |
|
|
|
605 |
} else {
|
|
|
606 |
promoterInfo = promoterRepository.selectAllPromoter(offset, limit);
|
|
|
607 |
|
|
|
608 |
size = promoterRepository.selectAllCount();
|
|
|
609 |
|
|
|
610 |
}
|
| 24159 |
tejbeer |
611 |
if (!promoterInfo.isEmpty()) {
|
|
|
612 |
List<Integer> partnerIds = new ArrayList<>();
|
|
|
613 |
|
|
|
614 |
for (Promoter promoterdetail : promoterInfo) {
|
|
|
615 |
partnerIds.add(promoterdetail.getRetailerId());
|
|
|
616 |
}
|
|
|
617 |
Map<Integer, CustomRetailer> partnersMap = null;
|
| 24349 |
amit.gupta |
618 |
if (!partnerIds.equals(null)) {
|
| 24159 |
tejbeer |
619 |
LOGGER.info("partnerIds" + partnerIds);
|
| 24349 |
amit.gupta |
620 |
partnersMap = retailerService.getFofoRetailers(partnerIds);
|
| 24159 |
tejbeer |
621 |
}
|
| 24349 |
amit.gupta |
622 |
|
| 24159 |
tejbeer |
623 |
LOGGER.info("partnerIds" + partnersMap);
|
|
|
624 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
625 |
model.addAttribute("partnersMap", partnersMap);
|
|
|
626 |
model.addAttribute("start", offset + 1);
|
|
|
627 |
model.addAttribute("size", size);
|
|
|
628 |
model.addAttribute("url", "/getPaginatedPromoterInfo");
|
|
|
629 |
|
|
|
630 |
if (promoterInfo.size() < limit) {
|
|
|
631 |
model.addAttribute("end", offset + promoterInfo.size());
|
|
|
632 |
} else {
|
|
|
633 |
model.addAttribute("end", offset + limit);
|
|
|
634 |
}
|
|
|
635 |
} else {
|
|
|
636 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
637 |
model.addAttribute("size", size);
|
|
|
638 |
}
|
|
|
639 |
return "promoter-info";
|
|
|
640 |
|
|
|
641 |
}
|
| 24349 |
amit.gupta |
642 |
|
| 24159 |
tejbeer |
643 |
@RequestMapping(value = "/getPaginatedPromoterInfo", method = RequestMethod.GET)
|
|
|
644 |
public String getPaginatedPromoterInfo(HttpServletRequest request,
|
|
|
645 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 27489 |
tejbeer |
646 |
@RequestParam(name = "limit", defaultValue = "10") int limit,
|
|
|
647 |
@RequestParam(name = "fofoId", required = false, defaultValue = "0") int fofoId, Model model)
|
| 24159 |
tejbeer |
648 |
throws ProfitMandiBusinessException {
|
|
|
649 |
LOGGER.info("requested offset=[{}], limit = [{}]", offset, limit);
|
|
|
650 |
List<Promoter> promoterInfo = null;
|
| 27489 |
tejbeer |
651 |
if (fofoId != 0) {
|
|
|
652 |
promoterInfo = promoterRepository.selectAllPromoterByFofoId(fofoId, offset, limit);
|
|
|
653 |
} else {
|
|
|
654 |
promoterInfo = promoterRepository.selectAllPromoter(offset, limit);
|
|
|
655 |
}
|
| 24159 |
tejbeer |
656 |
LOGGER.info("promoterInfo" + promoterInfo);
|
|
|
657 |
if (!promoterInfo.isEmpty()) {
|
|
|
658 |
List<Integer> partnerIds = new ArrayList<>();
|
|
|
659 |
|
|
|
660 |
for (Promoter promoterdetail : promoterInfo) {
|
|
|
661 |
partnerIds.add(promoterdetail.getRetailerId());
|
|
|
662 |
}
|
|
|
663 |
Map<Integer, CustomRetailer> partnersMap = null;
|
| 24349 |
amit.gupta |
664 |
if (!partnerIds.equals(null)) {
|
| 24159 |
tejbeer |
665 |
LOGGER.info("partnerIds" + partnerIds);
|
| 24349 |
amit.gupta |
666 |
partnersMap = retailerService.getFofoRetailers(partnerIds);
|
| 24159 |
tejbeer |
667 |
}
|
| 24349 |
amit.gupta |
668 |
|
| 24159 |
tejbeer |
669 |
LOGGER.info("partnerIds" + partnersMap);
|
|
|
670 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
671 |
model.addAttribute("partnersMap", partnersMap);
|
|
|
672 |
model.addAttribute("url", "/getPaginatedPromoterInfo");
|
|
|
673 |
} else {
|
|
|
674 |
model.addAttribute("promoterInfo", promoterInfo);
|
|
|
675 |
|
|
|
676 |
}
|
|
|
677 |
|
|
|
678 |
return "promoter-info-paginated";
|
|
|
679 |
}
|
|
|
680 |
|
|
|
681 |
@RequestMapping(value = "/createPromoter", method = RequestMethod.POST)
|
|
|
682 |
public String createPromoter(HttpServletRequest request, @RequestBody PromoterDetailModel promoterdetailModel,
|
|
|
683 |
Model model) throws Exception {
|
|
|
684 |
LOGGER.info("requested url : " + request.getRequestURL().toString());
|
|
|
685 |
LOGGER.info("requested url : " + promoterdetailModel);
|
| 26131 |
tejbeer |
686 |
Promoter promoter = promoterRepository.selectById(promoterdetailModel.getId());
|
|
|
687 |
if (promoter == null) {
|
|
|
688 |
promoter = new Promoter();
|
| 24159 |
tejbeer |
689 |
promoter.setBrand(promoterdetailModel.getBrand());
|
|
|
690 |
promoter.setRetailerId(promoterdetailModel.getRetailerId());
|
|
|
691 |
promoter.setCreatedTimestamp(LocalDateTime.now());
|
| 28996 |
amit.gupta |
692 |
promoter.setEmail(promoterdetailModel.getEmail());
|
|
|
693 |
promoter.setName(promoterdetailModel.getName());
|
|
|
694 |
promoter.setMobile(promoterdetailModel.getMobile());
|
|
|
695 |
promoter.setSdPortalAccess(promoterdetailModel.isSdPortalAccess());
|
|
|
696 |
promoter.setStatus(promoterdetailModel.isStatus());
|
| 28908 |
tejbeer |
697 |
promoterRepository.persist(promoter);
|
| 26131 |
tejbeer |
698 |
|
| 28908 |
tejbeer |
699 |
List<Promoter> promoters = promoterRepository.selectAllByRetailer(promoterdetailModel.getRetailerId());
|
|
|
700 |
if (!promoters.isEmpty()) {
|
| 28970 |
tejbeer |
701 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(promoterdetailModel.getRetailerId());
|
| 28908 |
tejbeer |
702 |
PartnerOnBoardingPanel pobp = partnerOnBoardingPanelRepository.selectByCode(fs.getCode());
|
|
|
703 |
if (pobp != null) {
|
|
|
704 |
storeTimelineTatService.promoterComplete(pobp.getId());
|
|
|
705 |
}
|
|
|
706 |
}
|
|
|
707 |
|
| 28996 |
amit.gupta |
708 |
} else {
|
|
|
709 |
promoter.setEmail(promoterdetailModel.getEmail());
|
|
|
710 |
promoter.setName(promoterdetailModel.getName());
|
|
|
711 |
promoter.setMobile(promoterdetailModel.getMobile());
|
|
|
712 |
promoter.setSdPortalAccess(promoterdetailModel.isSdPortalAccess());
|
|
|
713 |
promoter.setStatus(promoterdetailModel.isStatus());
|
| 24159 |
tejbeer |
714 |
}
|
| 27489 |
tejbeer |
715 |
LOGGER.info("sdport" + promoterdetailModel.isStatus());
|
| 24159 |
tejbeer |
716 |
|
|
|
717 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
718 |
|
|
|
719 |
return "response";
|
|
|
720 |
|
|
|
721 |
}
|
|
|
722 |
|
|
|
723 |
@RequestMapping(value = "/removePromoterfromPartnerStore", method = RequestMethod.POST)
|
|
|
724 |
public String removePromoterfromPartnerStore(HttpServletRequest request,
|
|
|
725 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
726 |
|
|
|
727 |
Promoter promoter = promoterRepository.selectById(id);
|
|
|
728 |
|
| 26131 |
tejbeer |
729 |
promoter.setStatus(false);
|
| 24159 |
tejbeer |
730 |
promoterRepository.persist(promoter);
|
|
|
731 |
|
|
|
732 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
733 |
|
|
|
734 |
return "response";
|
|
|
735 |
}
|
|
|
736 |
|
|
|
737 |
@RequestMapping(value = "/addLocation", method = RequestMethod.POST)
|
|
|
738 |
public String addLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel, Model model)
|
|
|
739 |
throws Exception {
|
|
|
740 |
|
|
|
741 |
Location location = new Location();
|
|
|
742 |
location.setName(addLocationModel.getName());
|
|
|
743 |
location.setLine1(addLocationModel.getLine1());
|
|
|
744 |
location.setLine2(addLocationModel.getLine2());
|
|
|
745 |
location.setCity(addLocationModel.getCity());
|
|
|
746 |
location.setState(addLocationModel.getState());
|
|
|
747 |
location.setPin(addLocationModel.getPin());
|
|
|
748 |
|
|
|
749 |
LOGGER.info("PostLocation" + location);
|
|
|
750 |
locationRepository.persist(location);
|
|
|
751 |
|
|
|
752 |
User user = userRepository.selectById(addLocationModel.getUserId());
|
|
|
753 |
user.setLocation(location.getId());
|
|
|
754 |
userRepository.persist(user);
|
|
|
755 |
|
|
|
756 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
757 |
return "response";
|
|
|
758 |
|
|
|
759 |
}
|
|
|
760 |
|
|
|
761 |
@RequestMapping(value = "/updateLocation", method = RequestMethod.POST)
|
|
|
762 |
public String updateLocation(HttpServletRequest request, @RequestBody AddLocationModel addLocationModel,
|
|
|
763 |
Model model) throws Exception {
|
|
|
764 |
|
|
|
765 |
Location userlocation = locationRepository.selectById(addLocationModel.getUserId());
|
|
|
766 |
|
|
|
767 |
userlocation.setName(addLocationModel.getName());
|
|
|
768 |
userlocation.setCity(addLocationModel.getCity());
|
|
|
769 |
userlocation.setLine1(addLocationModel.getLine1());
|
|
|
770 |
userlocation.setLine2(addLocationModel.getLine2());
|
|
|
771 |
userlocation.setPin(addLocationModel.getPin());
|
|
|
772 |
userlocation.setState(addLocationModel.getState());
|
|
|
773 |
|
|
|
774 |
locationRepository.persist(userlocation);
|
|
|
775 |
|
|
|
776 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
777 |
return "response";
|
|
|
778 |
|
|
|
779 |
}
|
|
|
780 |
|
| 27231 |
tejbeer |
781 |
@RequestMapping(value = "/getPartnerReadonlyInfo")
|
|
|
782 |
public String getPartnerReadonlyInfo(HttpServletRequest request, Model model) throws Exception {
|
|
|
783 |
|
|
|
784 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
785 |
AuthUser authUser = authRepository.selectByEmailOrMobile(loginDetails.getEmailId());
|
|
|
786 |
|
|
|
787 |
Map<Integer, List<Integer>> pp = csService.getAuthUserIdPartnerIdMapping();
|
|
|
788 |
|
|
|
789 |
List<Integer> fofoIds = pp.get(authUser.getId());
|
|
|
790 |
|
| 29604 |
amit.gupta |
791 |
Map<Integer, CustomRetailer> customRetailersMap = fofoIds.stream().map(x->{
|
|
|
792 |
try {
|
|
|
793 |
return retailerService.getFofoRetailer(x);
|
|
|
794 |
} catch (ProfitMandiBusinessException e) {
|
|
|
795 |
// TODO Auto-generated catch block
|
|
|
796 |
return null;
|
|
|
797 |
}
|
|
|
798 |
}).filter(x->x!=null).collect(Collectors.toMap(x->x.getPartnerId(), x->x));
|
| 27231 |
tejbeer |
799 |
|
|
|
800 |
model.addAttribute("customRetailersMap", customRetailersMap);
|
| 27243 |
tejbeer |
801 |
|
| 27231 |
tejbeer |
802 |
return "partner-readonly-info";
|
|
|
803 |
|
|
|
804 |
}
|
|
|
805 |
|
| 28071 |
tejbeer |
806 |
@RequestMapping(value = "/getBlockBrandMapping")
|
|
|
807 |
public String getBlockBrandMapping(HttpServletRequest request, Model model) throws Exception {
|
|
|
808 |
|
|
|
809 |
int fofoId = Utils.SYSTEM_PARTNER_ID;
|
|
|
810 |
Set<String> brands = null;
|
|
|
811 |
|
|
|
812 |
brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
|
|
813 |
.collect(Collectors.toSet());
|
|
|
814 |
|
|
|
815 |
LOGGER.info("brands" + brands);
|
|
|
816 |
model.addAttribute("brands", brands);
|
|
|
817 |
|
|
|
818 |
return "block-brand-mapping";
|
|
|
819 |
|
|
|
820 |
}
|
|
|
821 |
|
|
|
822 |
@RequestMapping(value = "/getBlockBrand")
|
|
|
823 |
public String getBlockBrand(HttpServletRequest request,
|
|
|
824 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
|
|
825 |
throws Exception {
|
|
|
826 |
|
|
|
827 |
List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
|
|
|
828 |
|
|
|
829 |
List<Integer> blockBrandPartners = retailerBlockBrands.stream().map(x -> x.getFofoId())
|
|
|
830 |
.collect(Collectors.toList());
|
|
|
831 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
| 28272 |
tejbeer |
832 |
|
| 28071 |
tejbeer |
833 |
LOGGER.info("retailerBlockBrands" + retailerBlockBrands);
|
|
|
834 |
model.addAttribute("blockBrandPartners", blockBrandPartners);
|
|
|
835 |
model.addAttribute("retailerBlockBrands", retailerBlockBrands);
|
|
|
836 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
837 |
|
|
|
838 |
return "retailer-block-brand";
|
|
|
839 |
|
|
|
840 |
}
|
|
|
841 |
|
|
|
842 |
@RequestMapping(value = "/getRetailerBlockBrandMappping", method = RequestMethod.POST)
|
|
|
843 |
public String getBlockBrandMappping(HttpServletRequest request,
|
|
|
844 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
845 |
@RequestParam(name = "fofoIds", required = true, defaultValue = "0") List<Integer> fofoIds, Model model)
|
|
|
846 |
throws Exception {
|
|
|
847 |
List<RetailerBlockBrands> retailerBlockBrands = retailerBlockBrandsRepository.selectAllByBrands(brand);
|
|
|
848 |
if (!retailerBlockBrands.isEmpty()) {
|
|
|
849 |
retailerBlockBrandsRepository.deleteAllbyBrands(brand);
|
|
|
850 |
}
|
|
|
851 |
|
|
|
852 |
for (int id : fofoIds) {
|
|
|
853 |
RetailerBlockBrands retailerBlockBrand = new RetailerBlockBrands();
|
|
|
854 |
retailerBlockBrand.setFofoId(id);
|
|
|
855 |
retailerBlockBrand.setBlockBrands(brand);
|
|
|
856 |
retailerBlockBrandsRepository.persist(retailerBlockBrand);
|
|
|
857 |
|
|
|
858 |
}
|
|
|
859 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
860 |
|
|
|
861 |
return "response";
|
|
|
862 |
}
|
|
|
863 |
|
| 28272 |
tejbeer |
864 |
@RequestMapping(value = "/getBrandslimit", method = RequestMethod.GET)
|
|
|
865 |
public String getBrandslimit(HttpServletRequest request, Model model) throws Exception {
|
|
|
866 |
|
|
|
867 |
int fofoId = Utils.SYSTEM_PARTNER_ID;
|
|
|
868 |
Set<String> brands = null;
|
|
|
869 |
|
|
|
870 |
brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
|
|
871 |
.collect(Collectors.toSet());
|
|
|
872 |
|
|
|
873 |
model.addAttribute("brands", brands);
|
|
|
874 |
|
|
|
875 |
return "brands-limit";
|
|
|
876 |
|
|
|
877 |
}
|
|
|
878 |
|
|
|
879 |
@RequestMapping(value = "/setUpdateLimit", method = RequestMethod.POST)
|
|
|
880 |
public String getUpdateLimit(HttpServletRequest request,
|
|
|
881 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand,
|
|
|
882 |
@RequestParam(name = "fofoId", required = true, defaultValue = "0") int fofoId,
|
|
|
883 |
@RequestParam(name = "limit", required = true, defaultValue = "0") float limit, Model model)
|
|
|
884 |
throws Exception {
|
|
|
885 |
|
|
|
886 |
CustomRetailer cr = retailerService.getFofoRetailer(fofoId);
|
| 28277 |
tejbeer |
887 |
|
|
|
888 |
Map.Entry<Integer, CustomRetailer> customRetailers = new AbstractMap.SimpleEntry(cr.getPartnerId(), cr);
|
|
|
889 |
|
|
|
890 |
// Map<Integer, CustomRetailer> customRetailers =
|
|
|
891 |
// retailerService.getFofoRetailers(true);
|
|
|
892 |
LOGGER.info("customRetailers" + customRetailers);
|
| 28272 |
tejbeer |
893 |
RetailerBrandsLimit retailerBrands = retailerBrandsLimitRepository.selectLimitByBrandAndFofoId(fofoId, brand);
|
| 28277 |
tejbeer |
894 |
|
| 28272 |
tejbeer |
895 |
if (retailerBrands == null) {
|
|
|
896 |
retailerBrands = new RetailerBrandsLimit();
|
|
|
897 |
retailerBrands.setBrandLimit(limit);
|
|
|
898 |
retailerBrands.setIsUpdate(1);
|
|
|
899 |
retailerBrands.setCreatedTimestamp(LocalDateTime.now());
|
|
|
900 |
retailerBrands.setPartnerId(fofoId);
|
|
|
901 |
retailerBrands.setBrandName(brand);
|
|
|
902 |
retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
903 |
retailerBrandsLimitRepository.persist(retailerBrands);
|
|
|
904 |
|
|
|
905 |
}
|
|
|
906 |
|
|
|
907 |
else {
|
|
|
908 |
retailerBrands.setBrandLimit(limit);
|
|
|
909 |
retailerBrands.setIsUpdate(1);
|
|
|
910 |
retailerBrands.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
911 |
retailerBrandsLimitRepository.persist(retailerBrands);
|
|
|
912 |
|
|
|
913 |
}
|
|
|
914 |
retailerBrands = retailerBrandsLimitRepository.selectLimitByBrandAndFofoId(fofoId, brand);
|
|
|
915 |
|
|
|
916 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = new HashMap<>();
|
|
|
917 |
|
|
|
918 |
retailerBrandsLimitMap.put(retailerBrands.getPartnerId(), retailerBrands);
|
|
|
919 |
|
|
|
920 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brand);
|
|
|
921 |
|
|
|
922 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
|
|
923 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
924 |
model.addAttribute("customRetailers", customRetailers);
|
| 28277 |
tejbeer |
925 |
|
|
|
926 |
model.addAttribute("brand", brand);
|
| 28272 |
tejbeer |
927 |
return "brands-limit-row-mapping";
|
|
|
928 |
|
|
|
929 |
}
|
|
|
930 |
|
|
|
931 |
@RequestMapping(value = "/getRetailerBrandslimitMapping", method = RequestMethod.GET)
|
|
|
932 |
public String getRetailerBrandslimit(HttpServletRequest request,
|
|
|
933 |
@RequestParam(name = "brand", required = true, defaultValue = "0") String brand, Model model)
|
|
|
934 |
throws Exception {
|
|
|
935 |
|
|
|
936 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
| 28283 |
tejbeer |
937 |
List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrands(brand);
|
|
|
938 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
|
|
|
939 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
| 28272 |
tejbeer |
940 |
|
|
|
941 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
942 |
model.addAttribute("brand", brand);
|
| 28283 |
tejbeer |
943 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
| 28272 |
tejbeer |
944 |
|
|
|
945 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brand);
|
|
|
946 |
|
|
|
947 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
948 |
|
|
|
949 |
return "brands-limit-mapping";
|
|
|
950 |
|
|
|
951 |
}
|
|
|
952 |
|
|
|
953 |
@RequestMapping(value = "/setBrandWiseLimit", method = RequestMethod.POST)
|
|
|
954 |
public String brandwiseLimit(HttpServletRequest request,
|
|
|
955 |
@RequestParam(name = "brands", required = true, defaultValue = "") String brands,
|
|
|
956 |
@RequestParam(name = "limit", required = true, defaultValue = "") float limit, Model model)
|
|
|
957 |
throws Exception {
|
|
|
958 |
|
|
|
959 |
LOGGER.info("limit" + limit);
|
|
|
960 |
|
|
|
961 |
BrandLimit brandLimit = brandLimitRepository.setLimitByBrands(brands);
|
|
|
962 |
|
|
|
963 |
List<RetailerBrandsLimit> retailerBrandsLimit = retailerBrandsLimitRepository.setAllLimitByBrands(brands);
|
|
|
964 |
|
|
|
965 |
Map<Integer, RetailerBrandsLimit> retailerBrandsLimitMap = retailerBrandsLimit.stream()
|
|
|
966 |
.collect(Collectors.toMap(x -> x.getPartnerId(), x -> x));
|
|
|
967 |
|
|
|
968 |
Map<Integer, CustomRetailer> customRetailers = retailerService.getFofoRetailers(true);
|
|
|
969 |
|
|
|
970 |
if (brandLimit == null) {
|
|
|
971 |
|
|
|
972 |
brandLimit = new BrandLimit();
|
|
|
973 |
brandLimit.setBrandLimit(limit);
|
|
|
974 |
brandLimit.setBrandName(brands);
|
|
|
975 |
brandLimit.setCreatedTimestamp(LocalDateTime.now());
|
|
|
976 |
brandLimit.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
977 |
brandLimitRepository.persist(brandLimit);
|
|
|
978 |
|
|
|
979 |
}
|
|
|
980 |
|
|
|
981 |
else {
|
|
|
982 |
brandLimit.setBrandLimit(limit);
|
|
|
983 |
|
|
|
984 |
brandLimit.setUpdatedTimestamp(LocalDateTime.now());
|
|
|
985 |
brandLimitRepository.persist(brandLimit);
|
|
|
986 |
|
|
|
987 |
}
|
|
|
988 |
brandLimit = brandLimitRepository.setLimitByBrands(brands);
|
|
|
989 |
|
|
|
990 |
LOGGER.info("brandLimit" + brandLimit);
|
| 28277 |
tejbeer |
991 |
model.addAttribute("brand", brands);
|
| 28272 |
tejbeer |
992 |
model.addAttribute("brandLimit", brandLimit);
|
|
|
993 |
model.addAttribute("customRetailers", customRetailers);
|
|
|
994 |
model.addAttribute("retailerBrandsLimitMap", retailerBrandsLimitMap);
|
|
|
995 |
return "brands-limit-mapping";
|
|
|
996 |
|
|
|
997 |
}
|
| 28825 |
tejbeer |
998 |
|
| 28381 |
tejbeer |
999 |
@RequestMapping(value = "/setPartnerPincode", method = RequestMethod.POST)
|
|
|
1000 |
public String setPartnerPincode(HttpServletRequest request,
|
|
|
1001 |
@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode,
|
| 28825 |
tejbeer |
1002 |
@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
|
|
|
1003 |
throws Exception {
|
| 28272 |
tejbeer |
1004 |
|
| 28825 |
tejbeer |
1005 |
if (!pincode.equals("")) {
|
|
|
1006 |
PincodePartner pinPartner = new PincodePartner();
|
|
|
1007 |
pinPartner.setFofoId(fofoId);
|
|
|
1008 |
pinPartner.setPincode(pincode);
|
|
|
1009 |
PincodePartnerRepository.perist(pinPartner);
|
| 28381 |
tejbeer |
1010 |
}
|
|
|
1011 |
|
| 28825 |
tejbeer |
1012 |
List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(fofoId);
|
|
|
1013 |
|
|
|
1014 |
LOGGER.info("partnerPincodeList" + partnerPincodeList);
|
|
|
1015 |
|
|
|
1016 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
| 28381 |
tejbeer |
1017 |
return "pincode-partner-index";
|
|
|
1018 |
|
|
|
1019 |
}
|
| 28825 |
tejbeer |
1020 |
|
| 28381 |
tejbeer |
1021 |
@RequestMapping(value = "/removePartnerPincode", method = RequestMethod.POST)
|
| 28825 |
tejbeer |
1022 |
public String removePartnerPincode(HttpServletRequest request, @RequestParam int id,
|
|
|
1023 |
@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
|
|
|
1024 |
throws Exception {
|
| 28381 |
tejbeer |
1025 |
|
| 28825 |
tejbeer |
1026 |
PincodePartnerRepository.delete(id);
|
| 28381 |
tejbeer |
1027 |
|
| 28825 |
tejbeer |
1028 |
List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(fofoId);
|
|
|
1029 |
|
|
|
1030 |
LOGGER.info("partnerPincodeList" + partnerPincodeList);
|
|
|
1031 |
|
|
|
1032 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
|
|
1033 |
|
| 28381 |
tejbeer |
1034 |
return "pincode-partner-index";
|
|
|
1035 |
|
|
|
1036 |
}
|
| 28825 |
tejbeer |
1037 |
|
| 28381 |
tejbeer |
1038 |
@RequestMapping(value = "/removeSearchPincode", method = RequestMethod.POST)
|
| 28825 |
tejbeer |
1039 |
public String removeSearchPincode(HttpServletRequest request, @RequestParam int id,
|
| 28381 |
tejbeer |
1040 |
@RequestParam(name = "pin", required = true, defaultValue = "") String pin,
|
| 28825 |
tejbeer |
1041 |
@RequestParam(name = "fofoId", required = true, defaultValue = "") int fofoId, Model model)
|
|
|
1042 |
throws Exception {
|
| 28381 |
tejbeer |
1043 |
|
| 28825 |
tejbeer |
1044 |
PincodePartnerRepository.delete(id);
|
| 28381 |
tejbeer |
1045 |
|
| 28825 |
tejbeer |
1046 |
List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectPartnersByPincode(pin);
|
| 28381 |
tejbeer |
1047 |
|
| 28825 |
tejbeer |
1048 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
|
|
1049 |
|
|
|
1050 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
|
|
1051 |
|
|
|
1052 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
|
|
1053 |
|
| 28381 |
tejbeer |
1054 |
return "search-pincode-partner";
|
|
|
1055 |
|
|
|
1056 |
}
|
| 28825 |
tejbeer |
1057 |
|
| 28381 |
tejbeer |
1058 |
@RequestMapping(value = "/searchPincodePartner", method = RequestMethod.GET)
|
|
|
1059 |
public String searchPincodePartner(HttpServletRequest request,
|
| 28825 |
tejbeer |
1060 |
@RequestParam(name = "pincode", required = true, defaultValue = "") String pincode, Model model)
|
|
|
1061 |
throws Exception {
|
| 28381 |
tejbeer |
1062 |
|
| 28825 |
tejbeer |
1063 |
List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectPartnersByPincode(pincode);
|
|
|
1064 |
|
| 28381 |
tejbeer |
1065 |
Map<Integer, CustomRetailer> customRetailerMap = retailerService.getFofoRetailers(true);
|
|
|
1066 |
|
|
|
1067 |
model.addAttribute("customRetailerMap", customRetailerMap);
|
| 28825 |
tejbeer |
1068 |
|
| 28381 |
tejbeer |
1069 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
| 28825 |
tejbeer |
1070 |
|
| 28381 |
tejbeer |
1071 |
return "search-pincode-partner";
|
| 28825 |
tejbeer |
1072 |
|
| 28381 |
tejbeer |
1073 |
}
|
| 28825 |
tejbeer |
1074 |
|
| 28381 |
tejbeer |
1075 |
@RequestMapping(value = "/showPartnerPincode", method = RequestMethod.GET)
|
|
|
1076 |
public String showPartnerPincode(HttpServletRequest request,
|
| 28825 |
tejbeer |
1077 |
@RequestParam(name = "partnerId", required = true, defaultValue = "") int partnerId, Model model)
|
|
|
1078 |
throws Exception {
|
| 28381 |
tejbeer |
1079 |
|
| 28825 |
tejbeer |
1080 |
List<PincodePartner> partnerPincodeList = PincodePartnerRepository.selectByPartnerId(partnerId);
|
|
|
1081 |
|
| 28381 |
tejbeer |
1082 |
model.addAttribute("partnerPincodeList", partnerPincodeList);
|
| 28825 |
tejbeer |
1083 |
|
| 28381 |
tejbeer |
1084 |
return "pincode-partner-index";
|
| 28825 |
tejbeer |
1085 |
|
| 28381 |
tejbeer |
1086 |
}
|
| 28825 |
tejbeer |
1087 |
|
| 28381 |
tejbeer |
1088 |
@RequestMapping(value = "/getAllPartnerPincode", method = RequestMethod.GET)
|
| 28825 |
tejbeer |
1089 |
public String getAllPartnerPincode(HttpServletRequest request, Model model) throws Exception {
|
| 28381 |
tejbeer |
1090 |
|
|
|
1091 |
return "add-partner-pincode";
|
| 28825 |
tejbeer |
1092 |
|
| 28381 |
tejbeer |
1093 |
}
|
| 28272 |
tejbeer |
1094 |
}
|