| Line 73... |
Line 73... |
| 73 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
73 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
| 74 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
74 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
| 75 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
75 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
| 76 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
76 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 77 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
77 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| - |
|
78 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 78 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
79 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 79 |
import com.spice.profitmandi.service.NotificationService;
|
80 |
import com.spice.profitmandi.service.NotificationService;
|
| 80 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
81 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 81 |
import com.spice.profitmandi.service.offers.OfferService;
|
82 |
import com.spice.profitmandi.service.offers.OfferService;
|
| 82 |
import com.spice.profitmandi.service.user.RetailerService;
|
83 |
import com.spice.profitmandi.service.user.RetailerService;
|
| Line 103... |
Line 104... |
| 103 |
@Autowired
|
104 |
@Autowired
|
| 104 |
private OfferPartnerRepository offerPartnerRepository;
|
105 |
private OfferPartnerRepository offerPartnerRepository;
|
| 105 |
|
106 |
|
| 106 |
private static final String IMAGE_REMOTE_DIR = "/var/www/dtrdashboard/uploads/campaigns/";
|
107 |
private static final String IMAGE_REMOTE_DIR = "/var/www/dtrdashboard/uploads/campaigns/";
|
| 107 |
private static final String IMAGE_STATIC_SERVER_URL = "https://images.smartdukaan.com/uploads/campaigns";
|
108 |
private static final String IMAGE_STATIC_SERVER_URL = "https://images.smartdukaan.com/uploads/campaigns";
|
| 108 |
|
109 |
|
| 109 |
@Autowired
|
110 |
@Autowired
|
| 110 |
private ItemRepository itemRepository;
|
111 |
private ItemRepository itemRepository;
|
| 111 |
|
112 |
|
| 112 |
@Autowired
|
113 |
@Autowired
|
| 113 |
private MVCResponseSender mvcResponseSender;
|
114 |
private MVCResponseSender mvcResponseSender;
|
| Line 159... |
Line 160... |
| 159 |
|
160 |
|
| 160 |
}
|
161 |
}
|
| 161 |
|
162 |
|
| 162 |
@RequestMapping(value = "/createOffer", method = RequestMethod.POST)
|
163 |
@RequestMapping(value = "/createOffer", method = RequestMethod.POST)
|
| 163 |
public String createOffer(HttpServletRequest request, @RequestBody CreateOfferRequest createOfferRequest,
|
164 |
public String createOffer(HttpServletRequest request, @RequestBody CreateOfferRequest createOfferRequest,
|
| 164 |
Model model) throws Exception {
|
165 |
Model model) throws Exception {
|
| 165 |
LOGGER.info("createOfferRequest [{}]", createOfferRequest);
|
166 |
LOGGER.info("createOfferRequest [{}]", createOfferRequest);
|
| 166 |
offerService.addOfferService(createOfferRequest);
|
167 |
offerService.addOfferService(createOfferRequest);
|
| 167 |
thirtyMinsTimeOutCacheManager.getCache("allOffers").evict(YearMonth.now());
|
168 |
thirtyMinsTimeOutCacheManager.getCache("allOffers").evict(YearMonth.now());
|
| 168 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
169 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 169 |
return "response";
|
170 |
return "response";
|
| Line 178... |
Line 179... |
| 178 |
return "scheme_offer/published";
|
179 |
return "scheme_offer/published";
|
| 179 |
|
180 |
|
| 180 |
}
|
181 |
}
|
| 181 |
|
182 |
|
| 182 |
@RequestMapping(value = "/offer/active/{offerId}", method = RequestMethod.GET)
|
183 |
@RequestMapping(value = "/offer/active/{offerId}", method = RequestMethod.GET)
|
| 183 |
public String activateOffer(HttpServletRequest request, @PathVariable int offerId, Model model, @RequestParam(defaultValue = "true") boolean active)
|
184 |
public String activateOffer(HttpServletRequest request, @PathVariable int offerId, Model model,
|
| 184 |
throws ProfitMandiBusinessException, Exception {
|
185 |
@RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
|
| 185 |
Offer offer = offerRepository.selectById(offerId);
|
186 |
Offer offer = offerRepository.selectById(offerId);
|
| 186 |
boolean alreadyActive = offer.isActive();
|
187 |
boolean alreadyActive = offer.isActive();
|
| 187 |
if(alreadyActive != active) {
|
188 |
if (alreadyActive != active) {
|
| 188 |
offer.setActive(active);
|
189 |
offer.setActive(active);
|
| 189 |
oneDayCacheManager.getCache("catalog.published_yearmonth").evict(YearMonth.now());
|
190 |
oneDayCacheManager.getCache("catalog.published_yearmonth").evict(YearMonth.now());
|
| 190 |
}
|
191 |
}
|
| 191 |
if(active && !alreadyActive) {
|
192 |
if (active && !alreadyActive) {
|
| 192 |
this.sendNotification(offer);
|
193 |
this.sendNotification(offer);
|
| 193 |
}
|
194 |
}
|
| 194 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
195 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 195 |
return "response";
|
196 |
return "response";
|
| - |
|
197 |
// CreateOfferRequest createOfferRequest =
|
| 196 |
//CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
198 |
// offerService.getCreateOfferRequest(offer);
|
| 197 |
//model.addAttribute("offer", createOfferRequest);
|
199 |
// model.addAttribute("offer", createOfferRequest);
|
| 198 |
//return "offer_margin_detail_partner2";
|
200 |
// return "offer_margin_detail_partner2";
|
| 199 |
}
|
201 |
}
|
| 200 |
|
202 |
|
| 201 |
@RequestMapping(value = "/offer/testimage/{offerId}", method = RequestMethod.GET)
|
203 |
@RequestMapping(value = "/offer/testimage/{offerId}", method = RequestMethod.GET)
|
| 202 |
public String testOffer(HttpServletRequest request, @PathVariable int offerId, Model model, @RequestParam(defaultValue = "true") boolean active)
|
204 |
public String testOffer(HttpServletRequest request, @PathVariable int offerId, Model model,
|
| 203 |
throws ProfitMandiBusinessException, Exception {
|
205 |
@RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
|
| 204 |
Offer offer = offerRepository.selectById(offerId);
|
206 |
Offer offer = offerRepository.selectById(offerId);
|
| 205 |
//model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
207 |
// model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 206 |
//return "response";
|
208 |
// return "response";
|
| 207 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
209 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
| 208 |
model.addAttribute("offer", createOfferRequest);
|
210 |
model.addAttribute("offer", createOfferRequest);
|
| 209 |
return "offer_margin_detail_partner2";
|
211 |
return "offer_margin_detail_partner2";
|
| 210 |
}
|
212 |
}
|
| 211 |
|
213 |
|
| 212 |
@Autowired
|
214 |
@Autowired
|
| 213 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
215 |
private com.spice.profitmandi.dao.repository.dtr.UserRepository dtrUserRepository;
|
| 214 |
|
216 |
|
| 215 |
@RequestMapping(value = "/offer/active/fofo/{fofoId}", method = RequestMethod.GET)
|
217 |
@RequestMapping(value = "/offer/active/fofo/{fofoId}", method = RequestMethod.GET)
|
| 216 |
public String sendOfferNotification(HttpServletRequest request, @PathVariable int fofoId, Model model, @RequestParam(defaultValue = "true") boolean active)
|
218 |
public String sendOfferNotification(HttpServletRequest request, @PathVariable int fofoId, Model model,
|
| 217 |
throws ProfitMandiBusinessException, Exception {
|
219 |
@RequestParam(defaultValue = "true") boolean active) throws ProfitMandiBusinessException, Exception {
|
| 218 |
List<Offer> offers = offerRepository.selectAllPublishedMapByPartner(YearMonth.now()).get(fofoId);
|
220 |
List<Offer> offers = offerRepository.selectAllPublishedMapByPartner(YearMonth.now()).get(fofoId);
|
| 219 |
for(Offer offer : offers) {
|
221 |
for (Offer offer : offers) {
|
| 220 |
this.sendNotification(offer);
|
222 |
this.sendNotification(offer);
|
| 221 |
}
|
223 |
}
|
| 222 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
224 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
| 223 |
return "response";
|
225 |
return "response";
|
| 224 |
}
|
226 |
}
|
| - |
|
227 |
|
| - |
|
228 |
@Autowired
|
| - |
|
229 |
UserAccountRepository userAccountRepository;
|
| 225 |
|
230 |
|
| 226 |
private void sendNotification(Offer offer) throws Exception {
|
231 |
private void sendNotification(Offer offer) throws Exception {
|
| 227 |
String fileName = "offer-" + offer.getId() + ".png";
|
232 |
String fileName = "offer-" + offer.getId() + ".png";
|
| 228 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
233 |
CreateOfferRequest createOfferRequest = offerService.getCreateOfferRequest(offer);
|
| 229 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
234 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 230 |
sendNotificationModel.setCampaignName("SchemeOffer");
|
235 |
sendNotificationModel.setCampaignName("SchemeOffer");
|
| 231 |
sendNotificationModel.setTitle(offer.getName());
|
236 |
sendNotificationModel.setTitle(offer.getName());
|
| 232 |
sendNotificationModel.setMessage(createOfferRequest.getSchemeType().name() + " of select models, "
|
237 |
sendNotificationModel.setMessage(createOfferRequest.getSchemeType().name() + " of select models, "
|
| 233 |
+ FormattingUtils.formatDateMonth(offer.getStartDate()) + " to " + FormattingUtils.formatDateMonth(offer.getEndDate()));
|
238 |
+ FormattingUtils.formatDateMonth(offer.getStartDate()) + " to "
|
| - |
|
239 |
+ FormattingUtils.formatDateMonth(offer.getEndDate()));
|
| 234 |
sendNotificationModel.setType("url");
|
240 |
sendNotificationModel.setType("url");
|
| 235 |
sendNotificationModel.setImageUrl(IMAGE_STATIC_SERVER_URL + "/" + "image" + LocalDate.now() + "/" + fileName);
|
241 |
sendNotificationModel.setImageUrl(IMAGE_STATIC_SERVER_URL + "/" + "image" + LocalDate.now() + "/" + fileName);
|
| 236 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
242 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 237 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
243 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 238 |
sendNotificationModel.setMessageType(MessageType.scheme);
|
244 |
sendNotificationModel.setMessageType(MessageType.scheme);
|
| 239 |
Map<Integer, Map<Integer, Long>> partnerWiseMap = null;
|
- |
|
| 240 |
Map<Integer, List<Offer>> offersMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
|
245 |
Map<Integer, List<Offer>> offersMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
|
| 241 |
List<Integer> fofoIds = offersMap.entrySet().stream().filter(x -> x.getValue().contains(offer))
|
246 |
List<Integer> fofoIds = offersMap.entrySet().stream().filter(x -> x.getValue().contains(offer))
|
| 242 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
247 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
| - |
|
248 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
| 243 |
sendNotificationModel.setFofoIds(fofoIds);
|
249 |
sendNotificationModel.setUserIds(userIds);
|
| 244 |
Map<String, InputStream> fileStreamsMap = new HashMap<>();
|
250 |
Map<String, InputStream> fileStreamsMap = new HashMap<>();
|
| - |
|
251 |
Map<String, Object> model = new HashMap<>();
|
| 245 |
List<Integer> dtrIds = dtrUserRepository
|
252 |
model.put("offer", createOfferRequest);
|
| 246 |
.selectAllByEmailIds(Arrays.asList("tarun.verma@smartdukaan.com", "amit.gupta@shop2020.in"))
|
253 |
String htmlContent = this.getContentFromTemplate("offer_margin_detail_partner.vm", model);
|
| - |
|
254 |
LOGGER.info("this.getContentFromTemplate {}", htmlContent);
|
| 247 |
.stream().map(x->x.getId()).collect(Collectors.toList());
|
255 |
fileStreamsMap.put(fileName, this.getImageBuffer(htmlContent));
|
| - |
|
256 |
|
| 248 |
sendNotificationModel.setUserIds(dtrIds);
|
257 |
this.uploadFile(fileStreamsMap);
|
| 249 |
notificationService.sendNotification(sendNotificationModel);
|
258 |
notificationService.sendNotification(sendNotificationModel);
|
| 250 |
try {
|
- |
|
| 251 |
Map<String, Object> model = new HashMap<>();
|
- |
|
| 252 |
model.put("offer", createOfferRequest);
|
- |
|
| 253 |
String htmlContent=this.getContentFromTemplate("offer_margin_detail_partner.vm", model);
|
- |
|
| 254 |
LOGGER.info("this.getContentFromTemplate {}", htmlContent);
|
- |
|
| 255 |
fileStreamsMap.put(fileName, this.getImageBuffer(htmlContent));
|
- |
|
| 256 |
this.uploadFile(fileStreamsMap);
|
- |
|
| 257 |
} catch (Exception e) {
|
- |
|
| 258 |
e.printStackTrace();
|
- |
|
| 259 |
}
|
- |
|
| 260 |
|
259 |
|
| 261 |
}
|
260 |
}
|
| 262 |
|
261 |
|
| 263 |
private InputStream asInputStream(BufferedImage bi) throws Exception {
|
262 |
private InputStream asInputStream(BufferedImage bi) throws Exception {
|
| 264 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
263 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
| 265 |
ImageIO.write(bi, "png", baos);
|
264 |
ImageIO.write(bi, "png", baos);
|
| 266 |
return new ByteArrayInputStream(baos.toByteArray());
|
265 |
return new ByteArrayInputStream(baos.toByteArray());
|
| 267 |
|
266 |
|
| 268 |
}
|
267 |
}
|
| 269 |
|
268 |
|
| 270 |
private ChannelSftp setupJsch() throws JSchException {
|
269 |
private ChannelSftp setupJsch() throws JSchException {
|
| 271 |
JSch jsch = new JSch();
|
270 |
JSch jsch = new JSch();
|
| 272 |
Session jschSession = jsch.getSession("root", "192.168.179.131");
|
271 |
Session jschSession = jsch.getSession("root", "192.168.179.131");
|
| 273 |
//Session jschSession = jsch.getSession("root", "173.255.254.24");
|
272 |
// Session jschSession = jsch.getSession("root", "173.255.254.24");
|
| - |
|
273 |
LOGGER.info("getClass().getResource(\"id_rsa\") {}",
|
| 274 |
LOGGER.info("getClass().getResource(\"id_rsa\") {}", getClass().getClassLoader().getResource("id_rsa").getPath());
|
274 |
getClass().getClassLoader().getResource("id_rsa").getPath());
|
| 275 |
jsch.addIdentity(getClass().getClassLoader().getResource("id_rsa").getPath());
|
275 |
jsch.addIdentity(getClass().getClassLoader().getResource("id_rsa").getPath());
|
| 276 |
//jschSession.setPassword("spic@2015static0");
|
276 |
// jschSession.setPassword("spic@2015static0");
|
| 277 |
jschSession.setConfig("StrictHostKeyChecking", "no");
|
277 |
jschSession.setConfig("StrictHostKeyChecking", "no");
|
| 278 |
jschSession.connect();
|
278 |
jschSession.connect();
|
| 279 |
return (ChannelSftp) jschSession.openChannel("sftp");
|
279 |
return (ChannelSftp) jschSession.openChannel("sftp");
|
| 280 |
}
|
280 |
}
|
| 281 |
|
281 |
|
| Line 305... |
Line 305... |
| 305 |
for (Map.Entry<String, InputStream> streamsFileEntry : streamsFileMap.entrySet()) {
|
305 |
for (Map.Entry<String, InputStream> streamsFileEntry : streamsFileMap.entrySet()) {
|
| 306 |
channelSftp.put(streamsFileEntry.getValue(), streamsFileEntry.getKey(), ChannelSftp.OVERWRITE);
|
306 |
channelSftp.put(streamsFileEntry.getValue(), streamsFileEntry.getKey(), ChannelSftp.OVERWRITE);
|
| 307 |
}
|
307 |
}
|
| 308 |
|
308 |
|
| 309 |
}
|
309 |
}
|
| 310 |
|
310 |
|
| 311 |
private void uploadFile(Map<String, InputStream> fileStreamsMap) throws Exception {
|
311 |
private void uploadFile(Map<String, InputStream> fileStreamsMap) throws Exception {
|
| 312 |
ChannelSftp channelSftp = setupJsch();
|
312 |
ChannelSftp channelSftp = setupJsch();
|
| 313 |
channelSftp.connect();
|
313 |
channelSftp.connect();
|
| 314 |
this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
|
314 |
this.fileUpload(channelSftp, fileStreamsMap, IMAGE_REMOTE_DIR + "");
|
| 315 |
channelSftp.exit();
|
315 |
channelSftp.exit();
|
| 316 |
}
|
316 |
}
|
| 317 |
|
317 |
|
| 318 |
private InputStream getImageBuffer (String html) throws Exception {
|
318 |
private InputStream getImageBuffer(String html) throws Exception {
|
| 319 |
|
319 |
|
| 320 |
String fileName = "/tmp/" + Instant.now().toEpochMilli();
|
320 |
String fileName = "/tmp/" + Instant.now().toEpochMilli();
|
| 321 |
FileUtils.writeStringToFile(new File(fileName), html, "UTF-8");
|
321 |
FileUtils.writeStringToFile(new File(fileName), html, "UTF-8");
|
| 322 |
String address = "file:" + fileName;
|
322 |
String address = "file:" + fileName;
|
| 323 |
Java2DRenderer renderer = new Java2DRenderer(address, 400);
|
323 |
Java2DRenderer renderer = new Java2DRenderer(address, 400);
|
| 324 |
RenderingHints hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING, RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
324 |
RenderingHints hints = new RenderingHints(RenderingHints.KEY_COLOR_RENDERING,
|
| - |
|
325 |
RenderingHints.VALUE_COLOR_RENDER_QUALITY);
|
| 325 |
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
|
326 |
hints.add(new RenderingHints(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY));
|
| 326 |
hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
|
327 |
hints.add(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON));
|
| 327 |
hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC));
|
328 |
hints.add(new RenderingHints(RenderingHints.KEY_INTERPOLATION, RenderingHints.VALUE_INTERPOLATION_BICUBIC));
|
| 328 |
renderer.setRenderingHints(hints);
|
329 |
renderer.setRenderingHints(hints);
|
| 329 |
BufferedImage img = renderer.getImage();
|
330 |
BufferedImage img = renderer.getImage();
|
| Line 395... |
Line 396... |
| 395 |
Arrays.asList("Id", "Name", "Target Type", "Scheme Type", "Brand %", "Sellin %", "Partner Criteria",
|
396 |
Arrays.asList("Id", "Name", "Target Type", "Scheme Type", "Brand %", "Sellin %", "Partner Criteria",
|
| 396 |
"Item Criteria", "Start", "End", "Created", "Partner Id", "Partner Name", "Partner Code",
|
397 |
"Item Criteria", "Start", "End", "Created", "Partner Id", "Partner Name", "Partner Code",
|
| 397 |
"Total Sale", "Eligible Sale", "Achieved Target", "Next Target", "Eligible Sale DP",
|
398 |
"Total Sale", "Eligible Sale", "Achieved Target", "Next Target", "Eligible Sale DP",
|
| 398 |
"Total Purchase DP", "Current Payout Target", "Payout Target Achieved", "Payout Amount Type",
|
399 |
"Total Purchase DP", "Current Payout Target", "Payout Target Achieved", "Payout Amount Type",
|
| 399 |
"Payout Value", "Payout Value DP", "Amount to be credited", "IMEIs pending for Activation"
|
400 |
"Payout Value", "Payout Value DP", "Amount to be credited", "IMEIs pending for Activation"
|
| 400 |
// "Payout Sale Qty", "Activated Value", "Activated Qty",
|
401 |
// "Payout Sale Qty", "Activated Value", "Activated Qty",
|
| 401 |
), listOfRows);
|
402 |
), listOfRows);
|
| 402 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
403 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| 403 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
404 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| 404 |
return new ResponseEntity<>(inputStreamResource, headers, HttpStatus.OK);
|
405 |
return new ResponseEntity<>(inputStreamResource, headers, HttpStatus.OK);
|
| 405 |
}
|
406 |
}
|
| Line 438... |
Line 439... |
| 438 |
@Autowired
|
439 |
@Autowired
|
| 439 |
RoleManager roleManager;
|
440 |
RoleManager roleManager;
|
| 440 |
|
441 |
|
| 441 |
@RequestMapping(value = "/getOfferMargins", method = RequestMethod.GET)
|
442 |
@RequestMapping(value = "/getOfferMargins", method = RequestMethod.GET)
|
| 442 |
public String getOfferMargins(HttpServletRequest request,
|
443 |
public String getOfferMargins(HttpServletRequest request,
|
| 443 |
@RequestParam(name = "offerId", defaultValue = "0") int offerId, Model model) throws Exception {
|
444 |
@RequestParam(name = "offerId", defaultValue = "0") int offerId, Model model) throws Exception {
|
| 444 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
445 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 445 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
446 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 446 |
CreateOfferRequest createOfferRequest = offerService.getOffer(isAdmin ? 0 : loginDetails.getFofoId(), offerId);
|
447 |
CreateOfferRequest createOfferRequest = offerService.getOffer(isAdmin ? 0 : loginDetails.getFofoId(), offerId);
|
| 447 |
|
448 |
|
| 448 |
model.addAttribute("offer", createOfferRequest);
|
449 |
model.addAttribute("offer", createOfferRequest);
|