| Line 5... |
Line 5... |
| 5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
5 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
6 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 7 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
7 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
| 8 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
8 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 9 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
9 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
| 10 |
import com.spice.profitmandi.common.util.FileUtil;
|
- |
|
| 11 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
10 |
import com.spice.profitmandi.common.util.FormattingUtils;
|
| 12 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
11 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 13 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
12 |
import com.spice.profitmandi.dao.entity.catalog.Offer;
|
| 14 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
13 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 15 |
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
|
14 |
import com.spice.profitmandi.dao.enumuration.catalog.ItemCriteriaType;
|
| 16 |
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
|
15 |
import com.spice.profitmandi.dao.enumuration.catalog.OfferSchemeType;
|
| 17 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
16 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
| 18 |
import com.spice.profitmandi.dao.model.OfferRowModel;
|
- |
|
| 19 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
17 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 20 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
18 |
import com.spice.profitmandi.dao.repository.catalog.OfferMarginRepository;
|
| 21 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
19 |
import com.spice.profitmandi.dao.repository.catalog.OfferPartnerRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
20 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
21 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| Line 407... |
Line 405... |
| 407 |
}
|
405 |
}
|
| 408 |
|
406 |
|
| 409 |
@RequestMapping(value = "/offerDownload", method = RequestMethod.GET)
|
407 |
@RequestMapping(value = "/offerDownload", method = RequestMethod.GET)
|
| 410 |
public ResponseEntity<?> dowloadOfferSummary(HttpServletRequest request, @RequestParam int offerId, Model model)
|
408 |
public ResponseEntity<?> dowloadOfferSummary(HttpServletRequest request, @RequestParam int offerId, Model model)
|
| 411 |
throws Exception {
|
409 |
throws Exception {
|
| 412 |
List<List<?>> listOfRows = new ArrayList<>();
|
- |
|
| 413 |
final HttpHeaders headers = new HttpHeaders();
|
410 |
final HttpHeaders headers = new HttpHeaders();
|
| 414 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
411 |
headers.set("Content-Type", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
|
| 415 |
headers.set("Content-disposition", "inline; filename=offer-" + offerId + ".csv");
|
412 |
headers.set("Content-disposition", "inline; filename=offer-" + offerId + ".csv");
|
| 416 |
CreateOfferRequest createOfferRequest = offerService.getOffer(0, offerId);
|
413 |
CreateOfferRequest createOfferRequest = offerService.getOffer(0, offerId);
|
| 417 |
Collection<OfferRowModel> offerRowModels = offerRepository.getOfferRows(createOfferRequest);
|
414 |
ByteArrayOutputStream baos = offerService.createCSVOfferReport(createOfferRequest);
|
| 418 |
ByteArrayOutputStream baos = null;
|
- |
|
| 419 |
if (createOfferRequest.getSchemeType().equals(OfferSchemeType.SELLIN)) {
|
- |
|
| 420 |
for (OfferRowModel offerRowModel : offerRowModels) {
|
- |
|
| 421 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(offerRowModel.getFofoId());
|
- |
|
| 422 |
listOfRows.add(Arrays.asList(createOfferRequest.getId(), createOfferRequest.getName(),
|
- |
|
| 423 |
createOfferRequest.getTargetType(), createOfferRequest.getSchemeType(),
|
- |
|
| 424 |
createOfferRequest.getBrandShareTerms(), createOfferRequest.getSellinPercentage(),
|
- |
|
| 425 |
"--", createOfferRequest.getItemCriteriaString(),
|
- |
|
| 426 |
createOfferRequest.getStartDate(), createOfferRequest.getEndDate(),
|
- |
|
| 427 |
createOfferRequest.getCreatedOn(), customRetailer.getPartnerId(), customRetailer.getBusinessName(),
|
- |
|
| 428 |
customRetailer.getCode(), offerRowModel.getTotalBasePurchaseValue(), offerRowModel.getAchievedTarget(),
|
- |
|
| 429 |
offerRowModel.getPayoutPurchaseValue(), offerRowModel.getPayout(), offerRowModel.getPayoutType(), offerRowModel.getFinalPayout(), String.join(", ", offerRowModel.getEligibleImeis())));
|
- |
|
| 430 |
}
|
- |
|
| 431 |
baos = FileUtil.getCSVByteStream(
|
- |
|
| 432 |
Arrays.asList("Id", "Name", "Target Type", "Scheme Type", "Brand %", "Sellin %", "Partner Criteria",
|
- |
|
| 433 |
"Item Criteria", "Start", "End", "Created", "Partner Id", "Partner Name", "Partner Code",
|
- |
|
| 434 |
"Base Purchase", "Achieved Target", "Eligible Purchase", "Slab Amount", "Slab Amount Type", "Payout Value(Rs.)",
|
- |
|
| 435 |
"Eligible IMEIs", "Billing Pending Imeis"
|
- |
|
| 436 |
), listOfRows);
|
- |
|
| 437 |
} else {
|
- |
|
| 438 |
for (OfferRowModel offerRowModel : offerRowModels) {
|
- |
|
| 439 |
CustomRetailer customRetailer = retailerService.getFofoRetailer(offerRowModel.getFofoId());
|
- |
|
| 440 |
listOfRows.add(Arrays.asList(createOfferRequest.getId(), createOfferRequest.getName(),
|
- |
|
| 441 |
createOfferRequest.getTargetType(), createOfferRequest.getSchemeType(),
|
- |
|
| 442 |
createOfferRequest.getBrandShareTerms(), createOfferRequest.getSellinPercentage(),
|
- |
|
| 443 |
createOfferRequest.getPartnerCriteriaString(), createOfferRequest.getItemCriteriaString(),
|
- |
|
| 444 |
createOfferRequest.getStartDate(), createOfferRequest.getEndDate(),
|
- |
|
| 445 |
createOfferRequest.getCreatedOn(), customRetailer.getPartnerId(), customRetailer.getBusinessName(),
|
- |
|
| 446 |
customRetailer.getCode(),
|
- |
|
| 447 |
|
- |
|
| 448 |
offerRowModel.getTotalSale(),
|
- |
|
| 449 |
offerRowModel.getEligibleSale(),
|
- |
|
| 450 |
offerRowModel.getPayoutTargetAchieved(),
|
- |
|
| 451 |
offerRowModel.getPayoutValue(),
|
- |
|
| 452 |
offerRowModel.getPayoutType(),
|
- |
|
| 453 |
offerRowModel.getPayoutValueDp(), offerRowModel.getFinalPayout(),
|
- |
|
| 454 |
String.join(", ", offerRowModel.getEligibleImeis()),
|
- |
|
| 455 |
String.join(", ", offerRowModel.getBaseCriteria()))
|
- |
|
| 456 |
);
|
- |
|
| 457 |
}
|
- |
|
| 458 |
baos = FileUtil.getCSVByteStream(
|
- |
|
| 459 |
Arrays.asList("Id", "Name", "Target Type", "Scheme Type", "Brand %", "Sellin %", "Partner Criteria",
|
- |
|
| 460 |
"Item Criteria", "Start", "End", "Created", "Partner Id", "Partner Name", "Partner Code",
|
- |
|
| 461 |
|
- |
|
| 462 |
"Total Value",
|
- |
|
| 463 |
"Eligible Value",
|
- |
|
| 464 |
"Payout Target Achieved", "Payout Amount", "Payout Amount Type",
|
- |
|
| 465 |
"Payout Value DP", "Amount to be credited", "Eligible Activated Imeis"
|
- |
|
| 466 |
), listOfRows);
|
- |
|
| 467 |
}
|
- |
|
| 468 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
415 |
final InputStream inputStream = new ByteArrayInputStream(baos.toByteArray());
|
| 469 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
416 |
final InputStreamResource inputStreamResource = new InputStreamResource(inputStream);
|
| 470 |
return new ResponseEntity<>(inputStreamResource, headers, HttpStatus.OK);
|
417 |
return new ResponseEntity<>(inputStreamResource, headers, HttpStatus.OK);
|
| 471 |
}
|
418 |
}
|
| 472 |
|
419 |
|
| 473 |
@RequestMapping(value = "/offerById", method = RequestMethod.GET)
|
420 |
@RequestMapping(value = "/offerById", method = RequestMethod.GET)
|
| 474 |
public String offerById(HttpServletRequest request, int offerId, Model model) throws ProfitMandiBusinessException {
|
421 |
public String offerById(HttpServletRequest request, int offerId, Model model) throws ProfitMandiBusinessException {
|
| 475 |
Offer offer = offerRepository.selectById(offerId);
|
422 |
Offer offer = offerRepository.selectById(offerId);
|
| 476 |
|
- |
|
| 477 |
model.addAttribute("offer", offer);
|
423 |
model.addAttribute("offer", offer);
|
| 478 |
|
- |
|
| 479 |
return "offer-edit";
|
424 |
return "offer-edit";
|
| 480 |
|
425 |
|
| 481 |
}
|
426 |
}
|
| 482 |
|
427 |
|
| 483 |
@RequestMapping(value = "/published-offers/{yearMonth}", method = RequestMethod.GET)
|
428 |
@RequestMapping(value = "/published-offers/{yearMonth}", method = RequestMethod.GET)
|