| Line 28... |
Line 28... |
| 28 |
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
|
28 |
import com.spice.profitmandi.dao.repository.inventory.VendorItemPricingRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
|
29 |
import com.spice.profitmandi.dao.repository.transaction.LineItemImeisRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
30 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropIMEIRepository;
|
| 31 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
31 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| 32 |
import com.spice.profitmandi.service.NotificationService;
|
32 |
import com.spice.profitmandi.service.NotificationService;
|
| - |
|
33 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 33 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
34 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 34 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
35 |
import com.spice.profitmandi.service.pricecircular.PriceCircularItemModel;
|
| 35 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
36 |
import com.spice.profitmandi.service.pricecircular.PriceCircularModel;
|
| 36 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
37 |
import com.spice.profitmandi.service.pricecircular.PriceCircularService;
|
| 37 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
38 |
import com.spice.profitmandi.service.pricing.PriceDropService;
|
| Line 108... |
Line 109... |
| 108 |
|
109 |
|
| 109 |
@Autowired
|
110 |
@Autowired
|
| 110 |
private PriceDropIMEIRepository priceDropIMEIRepository;
|
111 |
private PriceDropIMEIRepository priceDropIMEIRepository;
|
| 111 |
|
112 |
|
| 112 |
@Autowired
|
113 |
@Autowired
|
| - |
|
114 |
private RoleManager roleManager;
|
| - |
|
115 |
|
| - |
|
116 |
@Autowired
|
| 113 |
@Qualifier("catalogItemRepository")
|
117 |
@Qualifier("catalogItemRepository")
|
| 114 |
private ItemRepository itemRepository;
|
118 |
private ItemRepository itemRepository;
|
| 115 |
|
119 |
|
| 116 |
@Autowired
|
120 |
@Autowired
|
| 117 |
private SchemeService schemeService;
|
121 |
private SchemeService schemeService;
|
| Line 201... |
Line 205... |
| 201 |
return "response";
|
205 |
return "response";
|
| 202 |
}
|
206 |
}
|
| 203 |
|
207 |
|
| 204 |
@RequestMapping(value = "/item", method = RequestMethod.GET)
|
208 |
@RequestMapping(value = "/item", method = RequestMethod.GET)
|
| 205 |
public String getItemPricing(HttpServletRequest request, Model model, @RequestParam String query,
|
209 |
public String getItemPricing(HttpServletRequest request, Model model, @RequestParam String query,
|
| 206 |
@RequestParam boolean anyColor) throws Throwable {
|
210 |
@RequestParam boolean anyColor) throws Throwable {
|
| 207 |
String query1 = query.toLowerCase();
|
211 |
String query1 = query.toLowerCase();
|
| 208 |
|
212 |
|
| 209 |
List<ItemDescriptionModel> partnersItemDescription = inventoryService
|
213 |
List<ItemDescriptionModel> partnersItemDescription = inventoryService
|
| 210 |
.getAllPartnerItemStringDescription(anyColor).parallelStream()
|
214 |
.getAllPartnerItemStringDescription(anyColor).parallelStream()
|
| 211 |
.filter(x -> x.getItemDescription().toLowerCase().matches(".*?" + query1 + ".*?"))
|
215 |
.filter(x -> x.getItemDescription().toLowerCase().matches(".*?" + query1 + ".*?"))
|
| Line 216... |
Line 220... |
| 216 |
return "response";
|
220 |
return "response";
|
| 217 |
}
|
221 |
}
|
| 218 |
|
222 |
|
| 219 |
@RequestMapping(value = "/price-drop/imes/download")
|
223 |
@RequestMapping(value = "/price-drop/imes/download")
|
| 220 |
public ResponseEntity<ByteArrayResource> downloadPriceDropImeis(HttpServletRequest request,
|
224 |
public ResponseEntity<ByteArrayResource> downloadPriceDropImeis(HttpServletRequest request,
|
| 221 |
@RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
|
225 |
@RequestParam LocalDateTime affectedDate, @RequestParam int itemId) throws Exception {
|
| 222 |
Item item = itemRepository.selectById(itemId);
|
226 |
Item item = itemRepository.selectById(itemId);
|
| 223 |
ByteArrayOutputStream baos = getByteArrayOutputStream(affectedDate, item.getCatalogItemId(), null);
|
227 |
ByteArrayOutputStream baos = getByteArrayOutputStream(affectedDate, item.getCatalogItemId(), null);
|
| 224 |
final HttpHeaders headers = new HttpHeaders();
|
228 |
final HttpHeaders headers = new HttpHeaders();
|
| 225 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
229 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 226 |
headers.set("Content-disposition", "inline; filename=\"imei-" + item.getItemDescriptionNoColor() + ".csv\"");
|
230 |
headers.set("Content-disposition", "inline; filename=\"imei-" + item.getItemDescriptionNoColor() + ".csv\"");
|
| Line 229... |
Line 233... |
| 229 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
233 |
return new ResponseEntity<ByteArrayResource>(new ByteArrayResource(byteArray), headers, HttpStatus.OK);
|
| 230 |
}
|
234 |
}
|
| 231 |
|
235 |
|
| 232 |
@RequestMapping(value = "/price-drop/addPayout", method = RequestMethod.POST)
|
236 |
@RequestMapping(value = "/price-drop/addPayout", method = RequestMethod.POST)
|
| 233 |
public String updatePriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcessModel,
|
237 |
public String updatePriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcessModel,
|
| 234 |
Model model) throws Exception {
|
238 |
Model model) throws Exception {
|
| 235 |
boolean response = false;
|
239 |
boolean response = false;
|
| 236 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcessModel.getPriceDropId());
|
240 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcessModel.getPriceDropId());
|
| 237 |
if (priceDrop.getProcessTimestamp() == null) {
|
241 |
if (priceDrop.getProcessTimestamp() == null) {
|
| 238 |
priceDrop.setPartnerPayout(priceDropProcessModel.getPartnerPayout());
|
242 |
priceDrop.setPartnerPayout(priceDropProcessModel.getPartnerPayout());
|
| 239 |
priceDrop.setPriceDropIn(priceDropProcessModel.getPriceDropIn());
|
243 |
priceDrop.setPriceDropIn(priceDropProcessModel.getPriceDropIn());
|
| Line 287... |
Line 291... |
| 287 |
return "response";
|
291 |
return "response";
|
| 288 |
}
|
292 |
}
|
| 289 |
|
293 |
|
| 290 |
@RequestMapping(value = "/processPriceDrop", method = RequestMethod.POST)
|
294 |
@RequestMapping(value = "/processPriceDrop", method = RequestMethod.POST)
|
| 291 |
public String processPriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcessModel,
|
295 |
public String processPriceDrop(HttpServletRequest request, @RequestBody PriceDropProcessModel priceDropProcessModel,
|
| 292 |
Model model) throws Exception {
|
296 |
Model model) throws Exception {
|
| 293 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcessModel.getPriceDropId());
|
297 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropProcessModel.getPriceDropId());
|
| 294 |
boolean response = false;
|
298 |
boolean response = false;
|
| 295 |
if (priceDrop.getPartnerPayout() == 0) {
|
299 |
if (priceDrop.getPartnerPayout() == 0) {
|
| 296 |
priceDrop.setPartnerPayout(priceDropProcessModel.getPartnerPayout());
|
300 |
priceDrop.setPartnerPayout(priceDropProcessModel.getPartnerPayout());
|
| 297 |
}
|
301 |
}
|
| Line 375... |
Line 379... |
| 375 |
}
|
379 |
}
|
| 376 |
}
|
380 |
}
|
| 377 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
381 |
model.addAttribute("response", mvcResponseSender.createResponseString(response));
|
| 378 |
return "response";
|
382 |
return "response";
|
| 379 |
}
|
383 |
}
|
| - |
|
384 |
|
| 380 |
private void sendPriceChangeNotification(PriceDrop priceDrop) throws ProfitMandiBusinessException {
|
385 |
private void sendPriceChangeNotification(PriceDrop priceDrop) throws ProfitMandiBusinessException {
|
| 381 |
List<Item> items = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId());
|
386 |
List<Item> items = itemRepository.selectAllByCatalogItemId(priceDrop.getCatalogItemId());
|
| 382 |
String title = "Price has been %s for %s";
|
387 |
String title = "Price has been %s for %s";
|
| 383 |
|
388 |
|
| 384 |
|
389 |
|
| Line 386... |
Line 391... |
| 386 |
sendNotificationModel.setCampaignName("pricechange");
|
391 |
sendNotificationModel.setCampaignName("pricechange");
|
| 387 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
392 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 388 |
sendNotificationModel.setTitle("");
|
393 |
sendNotificationModel.setTitle("");
|
| 389 |
StringBuffer sb = new StringBuffer();
|
394 |
StringBuffer sb = new StringBuffer();
|
| 390 |
String message = null;
|
395 |
String message = null;
|
| 391 |
if(priceDrop.getDropAmount() > 0) {
|
396 |
if (priceDrop.getDropAmount() > 0) {
|
| 392 |
title = String.format(title, "dropped", items.get(0).getItemDescriptionNoColor());
|
397 |
title = String.format(title, "dropped", items.get(0).getItemDescriptionNoColor());
|
| 393 |
message = String.format("Price has been dropped from Rs.%d. Old DP - Rs.%d, New DP - Rs.%d", priceDrop.getDropAmount(),
|
398 |
message = String.format("Price has been dropped from Rs.%d. Old DP - Rs.%d, New DP - Rs.%d", priceDrop.getDropAmount(),
|
| 394 |
priceDrop.getOldDp(), priceDrop.getNewDp());
|
399 |
priceDrop.getOldDp(), priceDrop.getNewDp());
|
| 395 |
} else {
|
400 |
} else {
|
| 396 |
title = String.format(title, "increased", items.get(0).getItemDescriptionNoColor());
|
401 |
title = String.format(title, "increased", items.get(0).getItemDescriptionNoColor());
|
| Line 403... |
Line 408... |
| 403 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
408 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
| 404 |
}
|
409 |
}
|
| 405 |
|
410 |
|
| 406 |
@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
|
411 |
@RequestMapping(value = "/downloadtotalPriceDropIMEI/{priceDropId}", method = RequestMethod.GET)
|
| 407 |
public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
|
412 |
public ResponseEntity<?> downloadTotalPriceDropIMEI(HttpServletRequest request, @PathVariable int priceDropId,
|
| 408 |
Model model) throws ProfitMandiBusinessException, Exception {
|
413 |
Model model) throws ProfitMandiBusinessException, Exception {
|
| 409 |
|
414 |
|
| 410 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
|
415 |
PriceDrop priceDrop = priceDropRepository.selectById(priceDropId);
|
| 411 |
Map<String, PriceDropIMEI> priceDropIMEIsMap = priceDropIMEIRepository.selectByPriceDropId(priceDropId).stream()
|
416 |
Map<String, PriceDropIMEI> priceDropIMEIsMap = priceDropIMEIRepository.selectByPriceDropId(priceDropId).stream()
|
| 412 |
.collect(Collectors.toMap(x -> x.getImei(), x -> x));
|
417 |
.collect(Collectors.toMap(x -> x.getImei(), x -> x));
|
| 413 |
|
418 |
|
| Line 431... |
Line 436... |
| 431 |
|
436 |
|
| 432 |
}
|
437 |
}
|
| 433 |
|
438 |
|
| 434 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
439 |
@RequestMapping(value = "/updatePriceDropImeis", method = RequestMethod.POST)
|
| 435 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
440 |
public String updatePriceDropImeis(HttpServletRequest request, @RequestBody PriceDropImeisModel priceDropImeisModel,
|
| 436 |
Model model) throws ProfitMandiBusinessException, Exception {
|
441 |
Model model) throws ProfitMandiBusinessException, Exception {
|
| 437 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
442 |
PriceDropImeiStatus status = PriceDropImeiStatus.PENDING;
|
| 438 |
|
443 |
|
| 439 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
444 |
switch (priceDropImeisModel.getUpdatedStatus()) {
|
| 440 |
case "approved": {
|
445 |
case "approved": {
|
| 441 |
status = PriceDropImeiStatus.APPROVED;
|
446 |
status = PriceDropImeiStatus.APPROVED;
|
| 442 |
break;
|
447 |
break;
|
| 443 |
}
|
448 |
}
|
| 444 |
case "hold": {
|
449 |
case "hold": {
|
| 445 |
status = PriceDropImeiStatus.HOLD;
|
450 |
status = PriceDropImeiStatus.HOLD;
|
| 446 |
break;
|
451 |
break;
|
| 447 |
}
|
452 |
}
|
| 448 |
case "rejected": {
|
453 |
case "rejected": {
|
| 449 |
status = PriceDropImeiStatus.REJECTED;
|
454 |
status = PriceDropImeiStatus.REJECTED;
|
| 450 |
break;
|
455 |
break;
|
| 451 |
}
|
456 |
}
|
| 452 |
}
|
457 |
}
|
| 453 |
PriceDropImeiStatus finalStatus = status;
|
458 |
PriceDropImeiStatus finalStatus = status;
|
| 454 |
|
459 |
|
| 455 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
460 |
if (PriceDropImeiStatus.PENDING.equals(status)) {
|
| 456 |
|
461 |
|
| Line 512... |
Line 517... |
| 512 |
return "response";
|
517 |
return "response";
|
| 513 |
|
518 |
|
| 514 |
}
|
519 |
}
|
| 515 |
|
520 |
|
| 516 |
private ByteArrayOutputStream getByteArrayOutputStream(LocalDateTime affectedOn, Integer catalogItemId,
|
521 |
private ByteArrayOutputStream getByteArrayOutputStream(LocalDateTime affectedOn, Integer catalogItemId,
|
| 517 |
Map<String, PriceDropIMEI> priceDropImeis) throws Exception {
|
522 |
Map<String, PriceDropIMEI> priceDropImeis) throws Exception {
|
| 518 |
List<ImeiDropSummaryModel> imeiDropSummaryModelList = priceDropService
|
523 |
List<ImeiDropSummaryModel> imeiDropSummaryModelList = priceDropService
|
| 519 |
.getAllSerialNumbersByAffectedDate(affectedOn, catalogItemId);
|
524 |
.getAllSerialNumbersByAffectedDate(affectedOn, catalogItemId);
|
| 520 |
List<List<?>> rows = new ArrayList<>();
|
525 |
List<List<?>> rows = new ArrayList<>();
|
| 521 |
for (ImeiDropSummaryModel imeiDropSummaryModel : imeiDropSummaryModelList) {
|
526 |
for (ImeiDropSummaryModel imeiDropSummaryModel : imeiDropSummaryModelList) {
|
| 522 |
if (priceDropImeis == null) {
|
527 |
if (priceDropImeis == null) {
|
| Line 529... |
Line 534... |
| 529 |
"Model Name", "Model Number", "Color", "Status", "Rejection Reason", "Last Scanned", "Vendor Name",
|
534 |
"Model Name", "Model Number", "Color", "Status", "Rejection Reason", "Last Scanned", "Vendor Name",
|
| 530 |
"Grn On", "Activation Timestamp", "Activation Added On"), rows);
|
535 |
"Grn On", "Activation Timestamp", "Activation Added On"), rows);
|
| 531 |
}
|
536 |
}
|
| 532 |
|
537 |
|
| 533 |
private List<? extends Serializable> getRow(ImeiDropSummaryModel imeiDropSummaryModel,
|
538 |
private List<? extends Serializable> getRow(ImeiDropSummaryModel imeiDropSummaryModel,
|
| 534 |
PriceDropIMEI priceDropIMEI) {
|
539 |
PriceDropIMEI priceDropIMEI) {
|
| 535 |
List<Serializable> row = new ArrayList<>();
|
540 |
List<Serializable> row = new ArrayList<>();
|
| 536 |
row.add(imeiDropSummaryModel.getSerialNumber());
|
541 |
row.add(imeiDropSummaryModel.getSerialNumber());
|
| 537 |
row.add(imeiDropSummaryModel.getStoreName());
|
542 |
row.add(imeiDropSummaryModel.getStoreName());
|
| 538 |
row.add(imeiDropSummaryModel.getPartnerCode());
|
543 |
row.add(imeiDropSummaryModel.getPartnerCode());
|
| 539 |
row.add(imeiDropSummaryModel.getItemId());
|
544 |
row.add(imeiDropSummaryModel.getItemId());
|
| Line 573... |
Line 578... |
| 573 |
|
578 |
|
| 574 |
/*
|
579 |
/*
|
| 575 |
* Map<Integer, CustomRetailer> customRetailers =
|
580 |
* Map<Integer, CustomRetailer> customRetailers =
|
| 576 |
* retailerService.getFofoRetailers(true); Map<Integer, PartnerType>
|
581 |
* retailerService.getFofoRetailers(true); Map<Integer, PartnerType>
|
| 577 |
* fofoIdPartnerTypeMap = new HashMap<>();
|
582 |
* fofoIdPartnerTypeMap = new HashMap<>();
|
| 578 |
*
|
583 |
*
|
| 579 |
* for (Entry<Integer, CustomRetailer> customRetailer :
|
584 |
* for (Entry<Integer, CustomRetailer> customRetailer :
|
| 580 |
* customRetailers.entrySet()) { PartnerType partnerType =
|
585 |
* customRetailers.entrySet()) { PartnerType partnerType =
|
| 581 |
* partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
|
586 |
* partnerTypeChangeService.getTypeOnDate(customRetailer.getKey(),
|
| 582 |
* LocalDate.now()); fofoIdPartnerTypeMap.put(customRetailer.getKey(),
|
587 |
* LocalDate.now()); fofoIdPartnerTypeMap.put(customRetailer.getKey(),
|
| 583 |
* partnerType); }
|
588 |
* partnerType); }
|
| 584 |
*
|
589 |
*
|
| 585 |
* Map<PartnerType, List<Integer>> partnerTypePartnersMap =
|
590 |
* Map<PartnerType, List<Integer>> partnerTypePartnersMap =
|
| 586 |
* fofoIdPartnerTypeMap.entrySet().stream().collect( Collectors.groupingBy(x ->
|
591 |
* fofoIdPartnerTypeMap.entrySet().stream().collect( Collectors.groupingBy(x ->
|
| 587 |
* x.getValue(), Collectors.mapping(x -> x.getKey(), Collectors.toList())));
|
592 |
* x.getValue(), Collectors.mapping(x -> x.getKey(), Collectors.toList())));
|
| 588 |
*/
|
593 |
*/
|
| 589 |
model.addAttribute("brands", brands);
|
594 |
model.addAttribute("brands", brands);
|
| 590 |
model.addAttribute("date", LocalDate.now());
|
595 |
model.addAttribute("isAdmin", true);
|
| 591 |
|
596 |
|
| 592 |
return "price-circular";
|
597 |
return "partner-price-circular";
|
| 593 |
}
|
598 |
}
|
| 594 |
|
599 |
|
| 595 |
@RequestMapping(value = "/priceCircularByBrandAndPartnerType")
|
600 |
@RequestMapping(value = "/priceCircularByBrandAndPartnerType")
|
| 596 |
public String priceCircularByBrandAndPartnerType(HttpServletRequest request, @RequestParam List<String> brands,
|
601 |
public String priceCircularByBrandAndPartnerType(HttpServletRequest request, @RequestParam List<String> brands,
|
| 597 |
@RequestParam PartnerType partnerType, Model model) throws ProfitMandiBusinessException {
|
602 |
@RequestParam PartnerType partnerType, Model model) throws ProfitMandiBusinessException {
|
| 598 |
List<PartnerType> partnerTypes = new ArrayList<>();
|
603 |
List<PartnerType> partnerTypes = new ArrayList<>();
|
| 599 |
partnerTypes.add(partnerType);
|
604 |
partnerTypes.add(partnerType);
|
| 600 |
partnerTypes.add(PartnerType.ALL);
|
605 |
partnerTypes.add(PartnerType.ALL);
|
| 601 |
List<PriceCircularItemModel> priceCircular = tagListingRepository.getPriceCircularByBrandAndType(partnerTypes,
|
606 |
List<PriceCircularItemModel> priceCircular = tagListingRepository.getPriceCircularByBrandAndType(partnerTypes,
|
| 602 |
brands, LocalDateTime.now(), LocalDateTime.now().plusDays(1).toLocalDate().atStartOfDay());
|
607 |
brands, LocalDateTime.now(), LocalDateTime.now().plusDays(1).toLocalDate().atStartOfDay());
|
| Line 630... |
Line 635... |
| 630 |
Set<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
635 |
Set<String> brands = mongoClient.getMongoBrands(fofoId, null, 3).stream().map(x -> (String) x.get("name"))
|
| 631 |
.collect(Collectors.toSet());
|
636 |
.collect(Collectors.toSet());
|
| 632 |
brands.addAll(mongoClient.getMongoBrands(fofoId, null, 6).stream().map(x -> (String) x.get("name"))
|
637 |
brands.addAll(mongoClient.getMongoBrands(fofoId, null, 6).stream().map(x -> (String) x.get("name"))
|
| 633 |
.collect(Collectors.toSet()));
|
638 |
.collect(Collectors.toSet()));
|
| 634 |
model.addAttribute("brands", brands);
|
639 |
model.addAttribute("brands", brands);
|
| 635 |
model.addAttribute("date", LocalDate.now());
|
640 |
model.addAttribute("isAdmin", false);
|
| 636 |
|
641 |
|
| 637 |
return "partner-price-circular";
|
642 |
return "partner-price-circular";
|
| 638 |
}
|
643 |
}
|
| 639 |
|
644 |
|
| 640 |
@Autowired
|
645 |
@Autowired
|
| 641 |
PriceCircularService priceCircularService;
|
646 |
PriceCircularService priceCircularService;
|
| - |
|
647 |
|
| 642 |
@RequestMapping(value = "/priceCircularByBrand")
|
648 |
@RequestMapping(value = "/priceCircularByBrand")
|
| 643 |
public String priceCircularByBrand(HttpServletRequest request, @RequestParam String brand, Model model)
|
649 |
public String priceCircularByBrand(HttpServletRequest request, @RequestParam String brand, Model model, @RequestParam(defaultValue = "0", required = false) int fofoId)
|
| 644 |
throws ProfitMandiBusinessException {
|
650 |
throws ProfitMandiBusinessException {
|
| 645 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
651 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| - |
|
652 |
if (fofoId > 0 && roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| - |
|
653 |
} else {
|
| - |
|
654 |
fofoId = loginDetails.getFofoId();
|
| 646 |
|
655 |
}
|
| 647 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(loginDetails.getFofoId(), LocalDate.now());
|
656 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoId, LocalDate.now());
|
| 648 |
List<PartnerType> partnerTypes = new ArrayList<>();
|
657 |
List<PartnerType> partnerTypes = new ArrayList<>();
|
| 649 |
partnerTypes.add(partnerType);
|
658 |
partnerTypes.add(partnerType);
|
| 650 |
partnerTypes.add(PartnerType.ALL);
|
659 |
partnerTypes.add(PartnerType.ALL);
|
| 651 |
PriceCircularModel priceCircular = priceCircularService.getPriceCircularByOffer(loginDetails.getFofoId(), brand);
|
660 |
PriceCircularModel priceCircular = priceCircularService.getPriceCircularByOffer(fofoId, brand);
|
| 652 |
for (PriceCircularItemModel pc : priceCircular.getPriceCircularItemModels()) {
|
661 |
for (PriceCircularItemModel pc : priceCircular.getPriceCircularItemModels()) {
|
| 653 |
LOGGER.info("Slabs {}", pc.getSlabPayouts());
|
662 |
LOGGER.info("Slabs {}", pc.getSlabPayouts());
|
| 654 |
Long totalScheme = pc.getBasePayout() + pc.getCashDiscount()
|
663 |
Long totalScheme = pc.getBasePayout() + pc.getCashDiscount()
|
| 655 |
+ pc.getUpfrontMargin()
|
664 |
+ pc.getUpfrontMargin()
|
| 656 |
+ pc.getTertiaryPayout()
|
665 |
+ pc.getTertiaryPayout()
|
| 657 |
+ pc.getUpgradeOffer()
|
666 |
+ pc.getUpgradeOffer()
|
| 658 |
+ pc.getHygienePayout() + pc.getCategoryPayout() + pc.getInvestmentPayout() + pc.getModelSpecfic()
|
667 |
+ pc.getHygienePayout() + pc.getCategoryPayout() + pc.getInvestmentPayout() + pc.getModelSpecfic()
|
| 659 |
+ (pc.getSlabPayouts()==null ? 0l:pc.getSlabPayouts().stream().filter(x->x!=null).collect(Collectors.summingLong(x->x.entrySet().stream().findFirst().get().getValue())));
|
668 |
+ (pc.getSlabPayouts() == null ? 0l : pc.getSlabPayouts().stream().filter(x -> x != null).collect(Collectors.summingLong(x -> x.entrySet().stream().findFirst().get().getValue())));
|
| 660 |
pc.setTotalScheme(totalScheme);
|
669 |
pc.setTotalScheme(totalScheme);
|
| 661 |
long netprice = pc.getSellingPrice() - pc.getTotalScheme();
|
670 |
long netprice = pc.getSellingPrice() - pc.getTotalScheme();
|
| 662 |
pc.setNetPrice(netprice);
|
671 |
pc.setNetPrice(netprice);
|
| 663 |
int mopdpdiff = pc.getMop() - pc.getSellingPrice();
|
672 |
int mopdpdiff = pc.getMop() - pc.getSellingPrice();
|
| 664 |
pc.setMopdp(mopdpdiff);
|
673 |
pc.setMopdp(mopdpdiff);
|
| Line 668... |
Line 677... |
| 668 |
double rouoff = totalProfit / (pc.getSellingPrice() / 1.18) * 100;
|
677 |
double rouoff = totalProfit / (pc.getSellingPrice() / 1.18) * 100;
|
| 669 |
double roundOff = Math.round(rouoff * 100.0) / 100.0;
|
678 |
double roundOff = Math.round(rouoff * 100.0) / 100.0;
|
| 670 |
pc.setNetMargin(roundOff);
|
679 |
pc.setNetMargin(roundOff);
|
| 671 |
}
|
680 |
}
|
| 672 |
|
681 |
|
| 673 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
682 |
FofoStore fs = fofoStoreRepository.selectByRetailerId(fofoId);
|
| 674 |
model.addAttribute("priceCircular", priceCircular.getPriceCircularItemModels());
|
683 |
model.addAttribute("priceCircular", priceCircular.getPriceCircularItemModels());
|
| 675 |
model.addAttribute("offers", priceCircular.getOffers());
|
684 |
model.addAttribute("offers", priceCircular.getOffers());
|
| 676 |
model.addAttribute("upgradeOffer", priceCircular.isUpgradeOffer());
|
685 |
model.addAttribute("upgradeOffer", priceCircular.isUpgradeOffer());
|
| 677 |
model.addAttribute("partnerCode", fs.getCode());
|
686 |
model.addAttribute("partnerCode", fs.getCode());
|
| 678 |
return "price-circular-detail";
|
687 |
return "price-circular-detail";
|
| 679 |
}
|
688 |
}
|
| 680 |
|
689 |
|
| 681 |
@RequestMapping(value = "/selectPriceDropStatus", method = RequestMethod.GET)
|
690 |
@RequestMapping(value = "/selectPriceDropStatus", method = RequestMethod.GET)
|
| 682 |
public String selectPriceDropStatus(HttpServletRequest request,
|
691 |
public String selectPriceDropStatus(HttpServletRequest request,
|
| 683 |
@RequestParam(name = "selectedStatus", required = true, defaultValue = "") String selectedStatus,
|
692 |
@RequestParam(name = "selectedStatus", required = true, defaultValue = "") String selectedStatus,
|
| 684 |
Model model) throws Exception {
|
693 |
Model model) throws Exception {
|
| 685 |
|
694 |
|
| 686 |
model.addAttribute("selectedStatus", selectedStatus);
|
695 |
model.addAttribute("selectedStatus", selectedStatus);
|
| 687 |
return "pricedrop-status-change";
|
696 |
return "pricedrop-status-change";
|
| 688 |
}
|
697 |
}
|
| 689 |
|
698 |
|