| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.controller;
|
1 |
package com.spice.profitmandi.web.controller;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.net.URISyntaxException;
|
4 |
import java.net.URISyntaxException;
|
| 5 |
import java.time.LocalDateTime;
|
- |
|
| 6 |
import java.util.List;
|
5 |
import java.util.List;
|
| 7 |
|
6 |
|
| 8 |
import javax.servlet.http.HttpServletRequest;
|
7 |
import javax.servlet.http.HttpServletRequest;
|
| 9 |
|
8 |
|
| 10 |
import org.apache.logging.log4j.LogManager;
|
9 |
import org.apache.logging.log4j.LogManager;
|
| Line 24... |
Line 23... |
| 24 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
23 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 25 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
24 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 26 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
25 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 27 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
26 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 28 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
27 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 29 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderRepository;
|
28 |
import com.spice.profitmandi.dao.repository.fofo.PurchaseReturnItemRepository;
|
| 30 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
29 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 31 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
30 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 32 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
31 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| - |
|
32 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
| 33 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
33 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 34 |
import com.spice.profitmandi.service.wallet.WalletService;
|
34 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 35 |
import com.spice.profitmandi.web.model.LoginDetails;
|
35 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 36 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
36 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 37 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
37 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| Line 43... |
Line 43... |
| 43 |
@Value("${web.api.host}")
|
43 |
@Value("${web.api.host}")
|
| 44 |
private String webApiHost;
|
44 |
private String webApiHost;
|
| 45 |
|
45 |
|
| 46 |
@Value("${web.api.scheme}")
|
46 |
@Value("${web.api.scheme}")
|
| 47 |
private String webApiScheme;
|
47 |
private String webApiScheme;
|
| 48 |
|
48 |
|
| 49 |
@Value("${web.api.root}")
|
49 |
@Value("${web.api.root}")
|
| 50 |
private String webApiRoot;
|
50 |
private String webApiRoot;
|
| 51 |
|
51 |
|
| 52 |
@Value("${web.api.port}")
|
52 |
@Value("${web.api.port}")
|
| 53 |
private int webApiPort;
|
53 |
private int webApiPort;
|
| 54 |
|
54 |
|
| - |
|
55 |
|
| 55 |
@Autowired
|
56 |
@Autowired
|
| 56 |
private CookiesProcessor cookiesProcessor;
|
57 |
private CookiesProcessor cookiesProcessor;
|
| 57 |
|
58 |
|
| 58 |
@Autowired
|
59 |
@Autowired
|
| 59 |
private RoleManager roleManager;
|
60 |
private RoleManager roleManager;
|
| Line 64... |
Line 65... |
| 64 |
@Autowired
|
65 |
@Autowired
|
| 65 |
private WalletService walletService;
|
66 |
private WalletService walletService;
|
| 66 |
|
67 |
|
| 67 |
@Autowired
|
68 |
@Autowired
|
| 68 |
private InventoryService inventoryService;
|
69 |
private InventoryService inventoryService;
|
| - |
|
70 |
|
| - |
|
71 |
@Autowired
|
| - |
|
72 |
private TargetSlabService targetSlabService;
|
| 69 |
|
73 |
|
| 70 |
@Autowired
|
74 |
@Autowired
|
| 71 |
private OrderRepository orderRepository;
|
75 |
private OrderRepository orderRepository;
|
| 72 |
|
76 |
|
| 73 |
@Autowired
|
77 |
@Autowired
|
| 74 |
private FofoOrderRepository fofoOrderRepository;
|
78 |
private PurchaseReturnItemRepository purchaseReturnItemRepository;
|
| 75 |
|
79 |
|
| 76 |
/*
|
80 |
/*
|
| 77 |
* @Autowired private ScanRepository scanRepository;
|
81 |
* @Autowired private ScanRepository scanRepository;
|
| 78 |
*/
|
82 |
*/
|
| 79 |
|
83 |
|
| 80 |
@Autowired
|
84 |
@Autowired
|
| Line 112... |
Line 116... |
| 112 |
float unbilledStockAmount = 0;
|
116 |
float unbilledStockAmount = 0;
|
| 113 |
float grnPendingStockAmount = 0;
|
117 |
float grnPendingStockAmount = 0;
|
| 114 |
float shortPercentage = 100;
|
118 |
float shortPercentage = 100;
|
| 115 |
float totalInvestedAmount = 0;
|
119 |
float totalInvestedAmount = 0;
|
| 116 |
float minimumInvestment = 0;
|
120 |
float minimumInvestment = 0;
|
| 117 |
float returnedStockInTransit = 0;
|
121 |
float returnedStockInTransit=0;
|
| 118 |
double sale = 0;
|
122 |
float sale=0;
|
| 119 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
123 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
| 120 |
model.addAttribute("showAlert", false);
|
124 |
model.addAttribute("showAlert", false);
|
| 121 |
model.addAttribute("sale", sale);
|
125 |
model.addAttribute("sale", sale);
|
| 122 |
List<NotificationData> notificationData = null;
|
126 |
List<NotificationData> notificationData = null;
|
| 123 |
long size = 0;
|
127 |
long size = 0;
|
| Line 157... |
Line 161... |
| 157 |
|
161 |
|
| 158 |
}
|
162 |
}
|
| 159 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
163 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
| 160 |
walletAmount = walletService.getUserWallet(loginDetails.getFofoId()).getAmount();
|
164 |
walletAmount = walletService.getUserWallet(loginDetails.getFofoId()).getAmount();
|
| 161 |
inStockAmount = inventoryService.getTotalAmountInStock(loginDetails.getFofoId());
|
165 |
inStockAmount = inventoryService.getTotalAmountInStock(loginDetails.getFofoId());
|
| 162 |
sale = fofoOrderRepository.selectTotalSaleSumByFofoIdBrtweenDate(loginDetails.getFofoId(),
|
- |
|
| 163 |
LocalDateTime.of(LocalDateTime.now().getYear(), LocalDateTime.now().getMonth(), 01, 00, 00),
|
- |
|
| 164 |
LocalDateTime.now());
|
- |
|
| 165 |
|
166 |
|
| 166 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(loginDetails.getFofoId());
|
167 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(loginDetails.getFofoId());
|
| 167 |
for (Order unBilledOrder : unbilledOrders) {
|
168 |
for (Order unBilledOrder : unbilledOrders) {
|
| 168 |
unbilledStockAmount += unBilledOrder.getTotalAmount();
|
169 |
unbilledStockAmount += unBilledOrder.getTotalAmount();
|
| 169 |
}
|
170 |
}
|
| 170 |
|
171 |
|
| 171 |
List<Order> grnPendingOrders = orderRepository.selectPendingGrnOrders(loginDetails.getFofoId());
|
172 |
List<Order> grnPendingOrders = orderRepository.selectPendingGrnOrders(loginDetails.getFofoId());
|
| 172 |
for (Order grnPendingOrder : grnPendingOrders) {
|
173 |
for (Order grnPendingOrder : grnPendingOrders) {
|
| 173 |
grnPendingStockAmount += grnPendingOrder.getTotalAmount();
|
174 |
grnPendingStockAmount += grnPendingOrder.getTotalAmount();
|
| 174 |
}
|
175 |
}
|
| 175 |
totalInvestedAmount = walletAmount + inStockAmount + unbilledStockAmount + grnPendingStockAmount;
|
176 |
totalInvestedAmount = walletAmount + inStockAmount + unbilledStockAmount + grnPendingStockAmount + sale;
|
| 176 |
shortPercentage = ((fofoStore.getMinimumInvestment() - totalInvestedAmount)
|
177 |
shortPercentage = ((fofoStore.getMinimumInvestment() - totalInvestedAmount)
|
| 177 |
/ fofoStore.getMinimumInvestment()) * 100;
|
178 |
/ fofoStore.getMinimumInvestment()) * 100;
|
| 178 |
model.addAttribute("showAlert", shortPercentage > 10);
|
179 |
model.addAttribute("showAlert", shortPercentage > 10);
|
| 179 |
minimumInvestment = fofoStore.getMinimumInvestment();
|
180 |
minimumInvestment = fofoStore.getMinimumInvestment();
|
| 180 |
|
181 |
|
| Line 215... |
Line 216... |
| 215 |
model.addAttribute("size", size);
|
216 |
model.addAttribute("size", size);
|
| 216 |
LOGGER.info("sizeOriginal {}", size);
|
217 |
LOGGER.info("sizeOriginal {}", size);
|
| 217 |
|
218 |
|
| 218 |
}
|
219 |
}
|
| 219 |
}
|
220 |
}
|
| - |
|
221 |
model.addAttribute("sale", sale);
|
| 220 |
model.addAttribute("walletAmount", walletAmount);
|
222 |
model.addAttribute("walletAmount", walletAmount);
|
| 221 |
model.addAttribute("inStockAmount", inStockAmount);
|
223 |
model.addAttribute("inStockAmount", inStockAmount);
|
| 222 |
model.addAttribute("unbilledStockAmount", unbilledStockAmount);
|
224 |
model.addAttribute("unbilledStockAmount", unbilledStockAmount);
|
| 223 |
model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
|
225 |
model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
|
| 224 |
model.addAttribute("shortPercentage", shortPercentage);
|
226 |
model.addAttribute("shortPercentage", shortPercentage);
|
| Line 241... |
Line 243... |
| 241 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
243 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
| 242 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
244 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 243 |
return "dashboard";
|
245 |
return "dashboard";
|
| 244 |
}
|
246 |
}
|
| 245 |
|
247 |
|
| 246 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
248 |
//This method is currently hardcoded to faciliate watches sold as gift.
|
| 247 |
private boolean hasGift(int fofoId) {
|
249 |
private boolean hasGift(int fofoId) {
|
| 248 |
try {
|
250 |
try {
|
| 249 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
251 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId).getAvailability() > 0;
|
| 250 |
.getAvailability() > 0;
|
- |
|
| 251 |
} catch (ProfitMandiBusinessException e) {
|
252 |
} catch (ProfitMandiBusinessException e) {
|
| 252 |
return false;
|
253 |
return false;
|
| 253 |
}
|
254 |
}
|
| 254 |
}
|
255 |
}
|
| 255 |
|
- |
|
| 256 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
256 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
| 257 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
257 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
| 258 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
258 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 259 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
259 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 260 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
260 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| Line 299... |
Line 299... |
| 299 |
}
|
299 |
}
|
| 300 |
}
|
300 |
}
|
| 301 |
|
301 |
|
| 302 |
return "dashboard-paginated";
|
302 |
return "dashboard-paginated";
|
| 303 |
}
|
303 |
}
|
| 304 |
|
- |
|
| 305 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
304 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 306 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
305 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 307 |
model.addAttribute("appContextPath", request.getContextPath());
|
306 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 308 |
return "contact-us";
|
307 |
return "contact-us";
|
| 309 |
}
|
308 |
}
|