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