| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import static in.shop2020.model.v1.order.OrderStatus.BILLED;
|
- |
|
| 4 |
import static in.shop2020.model.v1.order.OrderStatus.DELIVERY_SUCCESS;
|
- |
|
| 5 |
import static in.shop2020.model.v1.order.OrderStatus.SHIPPED_FROM_WH;
|
- |
|
| 6 |
import static in.shop2020.model.v1.order.OrderStatus.SUBMITTED_FOR_PROCESSING;
|
- |
|
| 7 |
|
- |
|
| 8 |
import java.io.File;
|
- |
|
| 9 |
import java.io.FileInputStream;
|
- |
|
| 10 |
import java.io.FileNotFoundException;
|
- |
|
| 11 |
import java.time.LocalDate;
|
- |
|
| 12 |
import java.time.LocalDateTime;
|
- |
|
| 13 |
import java.time.LocalTime;
|
- |
|
| 14 |
import java.time.YearMonth;
|
- |
|
| 15 |
import java.time.format.DateTimeFormatter;
|
- |
|
| 16 |
import java.util.ArrayList;
|
- |
|
| 17 |
import java.util.Arrays;
|
- |
|
| 18 |
import java.util.Collections;
|
- |
|
| 19 |
import java.util.HashMap;
|
- |
|
| 20 |
import java.util.HashSet;
|
- |
|
| 21 |
import java.util.LinkedHashMap;
|
- |
|
| 22 |
import java.util.List;
|
- |
|
| 23 |
import java.util.Map;
|
- |
|
| 24 |
import java.util.Map.Entry;
|
- |
|
| 25 |
import java.util.NoSuchElementException;
|
- |
|
| 26 |
import java.util.Optional;
|
- |
|
| 27 |
import java.util.Set;
|
- |
|
| 28 |
import java.util.TreeMap;
|
- |
|
| 29 |
import java.util.stream.Collectors;
|
- |
|
| 30 |
|
- |
|
| 31 |
import javax.servlet.http.HttpServletRequest;
|
- |
|
| 32 |
import javax.transaction.Transactional;
|
- |
|
| 33 |
|
- |
|
| 34 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 35 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 36 |
import org.json.JSONObject;
|
- |
|
| 37 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 38 |
import org.springframework.beans.factory.annotation.Value;
|
- |
|
| 39 |
import org.springframework.core.io.InputStreamResource;
|
- |
|
| 40 |
import org.springframework.http.HttpHeaders;
|
- |
|
| 41 |
import org.springframework.http.HttpStatus;
|
- |
|
| 42 |
import org.springframework.http.ResponseEntity;
|
- |
|
| 43 |
import org.springframework.stereotype.Controller;
|
- |
|
| 44 |
import org.springframework.ui.Model;
|
- |
|
| 45 |
import org.springframework.web.bind.annotation.PathVariable;
|
- |
|
| 46 |
import org.springframework.web.bind.annotation.RequestMapping;
|
- |
|
| 47 |
import org.springframework.web.bind.annotation.RequestMethod;
|
- |
|
| 48 |
import org.springframework.web.bind.annotation.RequestParam;
|
- |
|
| 49 |
|
- |
|
| 50 |
import com.google.gson.Gson;
|
3 |
import com.google.gson.Gson;
|
| 51 |
import com.mongodb.DBObject;
|
4 |
import com.mongodb.DBObject;
|
| 52 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
5 |
import com.spice.profitmandi.common.enumuration.ContentType;
|
| 53 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
6 |
import com.spice.profitmandi.common.enumuration.MessageType;
|
| 54 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
7 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 55 |
import com.spice.profitmandi.common.model.ActivateItemModel;
|
- |
|
| 56 |
import com.spice.profitmandi.common.model.ChartInvestmentModel;
|
- |
|
| 57 |
import com.spice.profitmandi.common.model.ChartModel;
|
8 |
import com.spice.profitmandi.common.model.*;
|
| 58 |
import com.spice.profitmandi.common.model.CustomRetailer;
|
- |
|
| 59 |
import com.spice.profitmandi.common.model.Notification;
|
- |
|
| 60 |
import com.spice.profitmandi.common.model.OnlineDeliveredOrderSum;
|
- |
|
| 61 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
- |
|
| 62 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
9 |
import com.spice.profitmandi.common.web.util.ResponseSender;
|
| 63 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
10 |
import com.spice.profitmandi.dao.entity.auth.AuthUser;
|
| 64 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
11 |
import com.spice.profitmandi.dao.entity.catalog.Item;
|
| 65 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
12 |
import com.spice.profitmandi.dao.entity.catalog.TagListing;
|
| 66 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
13 |
import com.spice.profitmandi.dao.entity.cs.Position;
|
| 67 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
14 |
import com.spice.profitmandi.dao.entity.cs.TicketAssigned;
|
| 68 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
15 |
import com.spice.profitmandi.dao.entity.dtr.Document;
|
| 69 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
16 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
| 70 |
import com.spice.profitmandi.dao.entity.fofo.FofoLineItem;
|
- |
|
| 71 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrder;
|
- |
|
| 72 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
- |
|
| 73 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
17 |
import com.spice.profitmandi.dao.entity.fofo.*;
|
| 74 |
import com.spice.profitmandi.dao.entity.fofo.InventoryItem;
|
- |
|
| 75 |
import com.spice.profitmandi.dao.entity.fofo.MonthlyTarget;
|
- |
|
| 76 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
- |
|
| 77 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
18 |
import com.spice.profitmandi.dao.entity.transaction.LineItem;
|
| 78 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
19 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 79 |
import com.spice.profitmandi.dao.enumuration.catalog.UpgradeOfferStatus;
|
20 |
import com.spice.profitmandi.dao.enumuration.catalog.UpgradeOfferStatus;
|
| 80 |
import com.spice.profitmandi.dao.enumuration.fofo.Milestone;
|
21 |
import com.spice.profitmandi.dao.enumuration.fofo.Milestone;
|
| 81 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
22 |
import com.spice.profitmandi.dao.enumuration.transaction.OrderStatus;
|
| 82 |
import com.spice.profitmandi.dao.model.ActivationBrandModel;
|
- |
|
| 83 |
import com.spice.profitmandi.dao.model.ActivationImeiUpdationModel;
|
- |
|
| 84 |
import com.spice.profitmandi.dao.model.ActivationItemDetailModel;
|
- |
|
| 85 |
import com.spice.profitmandi.dao.model.ActivationYearMonthModel;
|
- |
|
| 86 |
import com.spice.profitmandi.dao.model.AllPurchaseInventoryModel;
|
- |
|
| 87 |
import com.spice.profitmandi.dao.model.BrandAmountModel;
|
- |
|
| 88 |
import com.spice.profitmandi.dao.model.BrandWiseActivatedModel;
|
- |
|
| 89 |
import com.spice.profitmandi.dao.model.BrandWisePartnerSaleModel;
|
- |
|
| 90 |
import com.spice.profitmandi.dao.model.BrandWiseUnbilledActivateStockModel;
|
- |
|
| 91 |
import com.spice.profitmandi.dao.model.CreateOfferRequest;
|
- |
|
| 92 |
import com.spice.profitmandi.dao.model.ImeiActivationTimestampModel;
|
- |
|
| 93 |
import com.spice.profitmandi.dao.model.InStockBrandItemModel;
|
- |
|
| 94 |
import com.spice.profitmandi.dao.model.InStockBrandModel;
|
- |
|
| 95 |
import com.spice.profitmandi.dao.model.ItemWiseTertiaryModel;
|
- |
|
| 96 |
import com.spice.profitmandi.dao.model.MonthSaleModel;
|
- |
|
| 97 |
import com.spice.profitmandi.dao.model.PartnerDetailModel;
|
- |
|
| 98 |
import com.spice.profitmandi.dao.model.PartnerMonthlySaleModel;
|
- |
|
| 99 |
import com.spice.profitmandi.dao.model.PartnerPendingIndentItemModel;
|
- |
|
| 100 |
import com.spice.profitmandi.dao.model.PriceDropBrandModel;
|
- |
|
| 101 |
import com.spice.profitmandi.dao.model.PriceDropWithDetailsByYearMonthModel;
|
- |
|
| 102 |
import com.spice.profitmandi.dao.model.PriceDropYearMonthModel;
|
- |
|
| 103 |
import com.spice.profitmandi.dao.model.SamsungUpgradeOfferModel;
|
23 |
import com.spice.profitmandi.dao.model.SamsungUpgradeOfferModel;
|
| 104 |
import com.spice.profitmandi.dao.model.UpgradeOfferItemDetailModel;
|
- |
|
| 105 |
import com.spice.profitmandi.dao.model.WarehouseBrandItemUnbilledActivatedModel;
|
- |
|
| 106 |
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemActivatedModel;
|
- |
|
| 107 |
import com.spice.profitmandi.dao.model.WarehouseBrandWiseItemSaleModel;
|
- |
|
| 108 |
import com.spice.profitmandi.dao.model.WarehouseWiseActivatedModel;
|
24 |
import com.spice.profitmandi.dao.model.*;
|
| 109 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandSaleModel;
|
- |
|
| 110 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandStockModel;
|
- |
|
| 111 |
import com.spice.profitmandi.dao.model.WarehouseWiseBrandUnbilledActivatedModel;
|
- |
|
| 112 |
import com.spice.profitmandi.dao.model.WarehouseWiseitemStockModel;
|
- |
|
| 113 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
25 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 114 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
26 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| - |
|
27 |
import com.spice.profitmandi.dao.repository.catalog.OfferRepository;
|
| 115 |
import com.spice.profitmandi.dao.repository.catalog.SamsungUpgradeOfferRepository;
|
28 |
import com.spice.profitmandi.dao.repository.catalog.SamsungUpgradeOfferRepository;
|
| 116 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
29 |
import com.spice.profitmandi.dao.repository.catalog.TagListingRepository;
|
| 117 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
30 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 118 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
31 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 119 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
32 |
import com.spice.profitmandi.dao.repository.cs.TicketAssignedRepository;
|
| 120 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
33 |
import com.spice.profitmandi.dao.repository.cs.TicketRepository;
|
| 121 |
import com.spice.profitmandi.dao.repository.dtr.DocumentRepository;
|
- |
|
| 122 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
- |
|
| 123 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
34 |
import com.spice.profitmandi.dao.repository.dtr.*;
|
| 124 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
- |
|
| 125 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
- |
|
| 126 |
import com.spice.profitmandi.dao.repository.fofo.ActivatedImeiRepository;
|
- |
|
| 127 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
- |
|
| 128 |
import com.spice.profitmandi.dao.repository.fofo.FofoLineItemRepository;
|
- |
|
| 129 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
- |
|
| 130 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
35 |
import com.spice.profitmandi.dao.repository.fofo.*;
|
| 131 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
- |
|
| 132 |
import com.spice.profitmandi.dao.repository.fofo.InventoryItemRepository;
|
- |
|
| 133 |
import com.spice.profitmandi.dao.repository.fofo.MonthlyTargetRepository;
|
- |
|
| 134 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
- |
|
| 135 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderItemRepository;
|
- |
|
| 136 |
import com.spice.profitmandi.dao.repository.fofo.PendingOrderRepository;
|
- |
|
| 137 |
import com.spice.profitmandi.dao.repository.fofo.SchemeInOutRepository;
|
- |
|
| 138 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
36 |
import com.spice.profitmandi.dao.repository.inventory.ReporticoCacheTableRepository;
|
| 139 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
37 |
import com.spice.profitmandi.dao.repository.inventory.SaholicInventoryCISRepository;
|
| 140 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
38 |
import com.spice.profitmandi.dao.repository.transaction.LineItemRepository;
|
| 141 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
39 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 142 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
40 |
import com.spice.profitmandi.dao.repository.transaction.PriceDropRepository;
|
| Line 150... |
Line 48... |
| 150 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
48 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 151 |
import com.spice.profitmandi.service.user.RetailerService;
|
49 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 152 |
import com.spice.profitmandi.web.model.LoginDetails;
|
50 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 153 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
51 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 154 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
52 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| - |
|
53 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
54 |
import org.apache.logging.log4j.Logger;
|
| - |
|
55 |
import org.json.JSONObject;
|
| - |
|
56 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
57 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
58 |
import org.springframework.core.io.InputStreamResource;
|
| - |
|
59 |
import org.springframework.http.HttpHeaders;
|
| - |
|
60 |
import org.springframework.http.HttpStatus;
|
| - |
|
61 |
import org.springframework.http.ResponseEntity;
|
| - |
|
62 |
import org.springframework.stereotype.Controller;
|
| - |
|
63 |
import org.springframework.ui.Model;
|
| - |
|
64 |
import org.springframework.web.bind.annotation.PathVariable;
|
| - |
|
65 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| - |
|
66 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
67 |
import org.springframework.web.bind.annotation.RequestParam;
|
| - |
|
68 |
|
| - |
|
69 |
import javax.servlet.http.HttpServletRequest;
|
| - |
|
70 |
import javax.transaction.Transactional;
|
| - |
|
71 |
import java.io.File;
|
| - |
|
72 |
import java.io.FileInputStream;
|
| - |
|
73 |
import java.io.FileNotFoundException;
|
| - |
|
74 |
import java.time.LocalDate;
|
| - |
|
75 |
import java.time.LocalDateTime;
|
| - |
|
76 |
import java.time.LocalTime;
|
| - |
|
77 |
import java.time.YearMonth;
|
| - |
|
78 |
import java.time.format.DateTimeFormatter;
|
| - |
|
79 |
import java.util.*;
|
| - |
|
80 |
import java.util.Map.Entry;
|
| - |
|
81 |
import java.util.stream.Collectors;
|
| - |
|
82 |
|
| - |
|
83 |
import static in.shop2020.model.v1.order.OrderStatus.*;
|
| 155 |
|
84 |
|
| 156 |
@Controller
|
85 |
@Controller
|
| 157 |
@Transactional(rollbackOn = Throwable.class)
|
86 |
@Transactional(rollbackOn = Throwable.class)
|
| 158 |
public class DashboardController {
|
87 |
public class DashboardController {
|
| 159 |
|
88 |
|
| Line 659... |
Line 588... |
| 659 |
model.addAttribute("shippedLineItemMap", shippedLineItemMap);
|
588 |
model.addAttribute("shippedLineItemMap", shippedLineItemMap);
|
| 660 |
}
|
589 |
}
|
| 661 |
return "purchase-shipped-order-status";
|
590 |
return "purchase-shipped-order-status";
|
| 662 |
}
|
591 |
}
|
| 663 |
|
592 |
|
| - |
|
593 |
|
| - |
|
594 |
@Autowired
|
| - |
|
595 |
OfferRepository offerRepository;
|
| - |
|
596 |
|
| 664 |
@RequestMapping(value = "/partnerTotalIncomeByMonth/{yearMonth}", method = RequestMethod.GET)
|
597 |
@RequestMapping(value = "/partnerTotalIncomeByMonth/{yearMonth}", method = RequestMethod.GET)
|
| 665 |
public String getPartnerTotalIncomeByMonth(HttpServletRequest request, @PathVariable int yearMonth, Model model)
|
598 |
public String getPartnerTotalIncomeByMonth(HttpServletRequest request, @PathVariable int yearMonth, Model model)
|
| 666 |
throws Exception {
|
599 |
throws Exception {
|
| 667 |
|
600 |
|
| 668 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
601 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 669 |
long pendingIncome = 0;
|
602 |
long pendingIncome = 0;
|
| 670 |
long partnerPurchaseIn = 0;
|
603 |
long partnerPurchaseIn = 0;
|
| 671 |
long partnerCreditedSale = 0;
|
604 |
long partnerCreditedSale = 0;
|
| 672 |
long partnerFrontIncome = 0;
|
605 |
long partnerFrontIncome = 0;
|
| 673 |
|
606 |
|
| 674 |
LocalDateTime currentStartMonth = LocalDate.now().minusMonths(yearMonth).withDayOfMonth(1).atStartOfDay();
|
607 |
LocalDateTime startOfMonth = LocalDate.now().minusMonths(yearMonth).withDayOfMonth(1).atStartOfDay();
|
| 675 |
LocalDateTime currentDate = currentStartMonth.plusMonths(1).withDayOfMonth(1).toLocalDate().atStartOfDay();
|
608 |
LocalDateTime endOfMonth = startOfMonth.plusMonths(1).toLocalDate().atStartOfDay();
|
| 676 |
|
609 |
|
| 677 |
AllPurchaseInventoryModel partnerlPendingSaleAmount = schemeInOutRepository
|
610 |
AllPurchaseInventoryModel partnerlPendingSaleAmount = schemeInOutRepository
|
| 678 |
.selectAllPendingSaleInventoryByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate);
|
611 |
.selectAllPendingSaleInventoryByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
| 679 |
AllPurchaseInventoryModel partnerCreditedSaleAmount = schemeInOutRepository
|
612 |
AllPurchaseInventoryModel partnerCreditedSaleAmount = schemeInOutRepository
|
| 680 |
.selectAllCreditedSaleInventoryByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate);
|
613 |
.selectAllCreditedSaleInventoryByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
| 681 |
AllPurchaseInventoryModel partnerPurchaseInAmount = schemeInOutRepository
|
614 |
AllPurchaseInventoryModel partnerPurchaseInAmount = schemeInOutRepository
|
| 682 |
.selectAllPurchaseInventoryByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate);
|
615 |
.selectAllPurchaseInventoryByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
| 683 |
|
616 |
|
| 684 |
AllPurchaseInventoryModel partnerFrontIncomes = schemeInOutRepository
|
617 |
AllPurchaseInventoryModel partnerFrontIncomes = schemeInOutRepository
|
| 685 |
.selectFrontIncomeByFofoId(loginDetails.getFofoId(), currentStartMonth, currentDate);
|
618 |
.selectFrontIncomeByFofoId(loginDetails.getFofoId(), startOfMonth, endOfMonth);
|
| - |
|
619 |
|
| - |
|
620 |
AllPurchaseInventoryModel partnerAdditionalIncome = offerRepository.selectPurchaseIncome(loginDetails.getFofoId(), startOfMonth, endOfMonth)
|
| 686 |
|
621 |
|
| 687 |
LOGGER.info("partnerfrontIncomes" + partnerFrontIncomes);
|
622 |
LOGGER.info("partnerfrontIncomes" + partnerFrontIncomes);
|
| 688 |
|
623 |
|
| 689 |
LOGGER.info("partnerCreditedSaleAmount" + partnerCreditedSaleAmount);
|
624 |
LOGGER.info("partnerCreditedSaleAmount" + partnerCreditedSaleAmount);
|
| 690 |
LOGGER.info("partnerPurchaseInAmount" + partnerPurchaseInAmount);
|
625 |
LOGGER.info("partnerPurchaseInAmount" + partnerPurchaseInAmount);
|