| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 23568 |
govind |
3 |
import java.io.IOException;
|
|
|
4 |
import java.net.URISyntaxException;
|
| 24288 |
amit.gupta |
5 |
import java.time.DayOfWeek;
|
|
|
6 |
import java.time.LocalDate;
|
| 24276 |
amit.gupta |
7 |
import java.time.LocalDateTime;
|
| 24288 |
amit.gupta |
8 |
import java.time.temporal.TemporalAdjusters;
|
| 23884 |
amit.gupta |
9 |
import java.util.List;
|
| 23568 |
govind |
10 |
|
| 22086 |
amit.gupta |
11 |
import javax.servlet.http.HttpServletRequest;
|
|
|
12 |
|
| 23786 |
amit.gupta |
13 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
14 |
import org.apache.logging.log4j.Logger;
|
| 24321 |
amit.gupta |
15 |
import org.json.JSONArray;
|
|
|
16 |
import org.json.JSONObject;
|
| 22481 |
ashik.ali |
17 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
18 |
import org.springframework.beans.factory.annotation.Value;
|
| 21615 |
kshitij.so |
19 |
import org.springframework.stereotype.Controller;
|
| 22481 |
ashik.ali |
20 |
import org.springframework.transaction.annotation.Transactional;
|
| 22073 |
ashik.ali |
21 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
22 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
23 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 24098 |
tejbeer |
24 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
25 |
|
| 22481 |
ashik.ali |
26 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24203 |
amit.gupta |
27 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 24098 |
tejbeer |
28 |
import com.spice.profitmandi.dao.entity.dtr.NotificationData;
|
| 22654 |
ashik.ali |
29 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 24288 |
amit.gupta |
30 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 23884 |
amit.gupta |
31 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 22481 |
ashik.ali |
32 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24098 |
tejbeer |
33 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 24203 |
amit.gupta |
34 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24288 |
amit.gupta |
35 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 23884 |
amit.gupta |
36 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| 23844 |
amit.gupta |
37 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23884 |
amit.gupta |
38 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
|
|
39 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
|
|
40 |
import com.spice.profitmandi.service.wallet.WalletService;
|
| 22481 |
ashik.ali |
41 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
42 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24263 |
tejbeer |
43 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
44 |
|
| 21615 |
kshitij.so |
45 |
@Controller
|
| 22481 |
ashik.ali |
46 |
@Transactional(rollbackFor = Throwable.class)
|
| 21615 |
kshitij.so |
47 |
public class DashboardController {
|
| 23923 |
amit.gupta |
48 |
|
| 24321 |
amit.gupta |
49 |
private static final String IN_TRANSIT_STACK = "inTransitStack";
|
|
|
50 |
|
|
|
51 |
private static final String BILLING_PENDING_STACK = "billingPendingStack";
|
|
|
52 |
|
|
|
53 |
private static final String GRN_PENDING_STACK = "grnPendingStack";
|
|
|
54 |
|
|
|
55 |
private static final String SALES_STACK = "salesStack";
|
|
|
56 |
|
|
|
57 |
private static final String IN_STOCK_STACK = "inStockStack";
|
|
|
58 |
|
|
|
59 |
private static final String WALLET_STACK = "walletStack";
|
|
|
60 |
|
| 23379 |
ashik.ali |
61 |
@Value("${web.api.host}")
|
|
|
62 |
private String webApiHost;
|
| 23923 |
amit.gupta |
63 |
|
| 24072 |
amit.gupta |
64 |
@Value("${web.api.scheme}")
|
|
|
65 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
66 |
|
| 24078 |
amit.gupta |
67 |
@Value("${web.api.root}")
|
|
|
68 |
private String webApiRoot;
|
|
|
69 |
|
| 23379 |
ashik.ali |
70 |
@Value("${web.api.port}")
|
|
|
71 |
private int webApiPort;
|
| 21615 |
kshitij.so |
72 |
|
| 22481 |
ashik.ali |
73 |
@Autowired
|
| 22927 |
ashik.ali |
74 |
private CookiesProcessor cookiesProcessor;
|
| 23923 |
amit.gupta |
75 |
|
| 23568 |
govind |
76 |
@Autowired
|
| 23786 |
amit.gupta |
77 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
78 |
|
| 23838 |
ashik.ali |
79 |
@Autowired
|
|
|
80 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
81 |
|
|
|
82 |
@Autowired
|
|
|
83 |
private WalletService walletService;
|
| 23923 |
amit.gupta |
84 |
|
| 23884 |
amit.gupta |
85 |
@Autowired
|
|
|
86 |
private InventoryService inventoryService;
|
| 24288 |
amit.gupta |
87 |
|
| 23923 |
amit.gupta |
88 |
|
| 23884 |
amit.gupta |
89 |
@Autowired
|
|
|
90 |
private OrderRepository orderRepository;
|
| 24288 |
amit.gupta |
91 |
|
|
|
92 |
|
|
|
93 |
@Autowired
|
|
|
94 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
|
|
95 |
|
| 23923 |
amit.gupta |
96 |
/*
|
|
|
97 |
* @Autowired private ScanRepository scanRepository;
|
|
|
98 |
*/
|
|
|
99 |
|
| 23884 |
amit.gupta |
100 |
@Autowired
|
|
|
101 |
private TransactionService transactionService;
|
| 24263 |
tejbeer |
102 |
|
| 24098 |
tejbeer |
103 |
@Autowired
|
| 24263 |
tejbeer |
104 |
private MVCResponseSender mvcResponseSender;
|
|
|
105 |
|
|
|
106 |
@Autowired
|
| 24098 |
tejbeer |
107 |
private NotificationPanelRepository notificationPanelRepository;
|
| 23923 |
amit.gupta |
108 |
|
| 24203 |
amit.gupta |
109 |
@Autowired
|
|
|
110 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
111 |
|
| 23568 |
govind |
112 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
113 |
|
| 21615 |
kshitij.so |
114 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 24312 |
amit.gupta |
115 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
| 24098 |
tejbeer |
116 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model)
|
| 23923 |
amit.gupta |
117 |
throws ProfitMandiBusinessException, URISyntaxException, IOException {
|
|
|
118 |
// LOGGER.info("scanRepository.selectScansByInventoryItemId(1)",
|
|
|
119 |
// scanRepository.selectScansByInventoryItemId(1));
|
| 23884 |
amit.gupta |
120 |
LOGGER.info("In Dashboard");
|
| 22927 |
ashik.ali |
121 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 23923 |
amit.gupta |
122 |
|
| 22481 |
ashik.ali |
123 |
FofoStore fofoStore = null;
|
|
|
124 |
try {
|
| 22927 |
ashik.ali |
125 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
126 |
} catch (ProfitMandiBusinessException e) {
|
| 22927 |
ashik.ali |
127 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 22481 |
ashik.ali |
128 |
}
|
| 23884 |
amit.gupta |
129 |
|
| 23923 |
amit.gupta |
130 |
float walletAmount = 0;
|
|
|
131 |
float inStockAmount = 0;
|
|
|
132 |
float unbilledStockAmount = 0;
|
|
|
133 |
float grnPendingStockAmount = 0;
|
|
|
134 |
float shortPercentage = 100;
|
|
|
135 |
float totalInvestedAmount = 0;
|
| 23936 |
tejbeer |
136 |
float minimumInvestment = 0;
|
| 24312 |
amit.gupta |
137 |
float returnedStockInTransit = 0;
|
|
|
138 |
float sale = 0;
|
| 23923 |
amit.gupta |
139 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
140 |
model.addAttribute("showAlert", false);
|
| 24263 |
tejbeer |
141 |
model.addAttribute("sale", sale);
|
|
|
142 |
List<NotificationData> notificationData = null;
|
|
|
143 |
long size = 0;
|
|
|
144 |
|
|
|
145 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
|
|
146 |
size = notificationPanelRepository.selectAllCount();
|
|
|
147 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
148 |
|
|
|
149 |
LOGGER.info("notification_data {}", size);
|
|
|
150 |
|
|
|
151 |
if (!notificationData.isEmpty()) {
|
|
|
152 |
|
|
|
153 |
model.addAttribute("notificationData", notificationData);
|
|
|
154 |
LOGGER.info("notificationdata", notificationData);
|
|
|
155 |
model.addAttribute("start", offset + 1);
|
|
|
156 |
model.addAttribute("size", size);
|
|
|
157 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
158 |
|
|
|
159 |
LOGGER.info("start {}", offset + 1);
|
|
|
160 |
LOGGER.info("SIZE {}", size);
|
|
|
161 |
|
|
|
162 |
if (notificationData.size() < limit) {
|
|
|
163 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
164 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
165 |
} else {
|
|
|
166 |
model.addAttribute("end", offset + limit);
|
|
|
167 |
|
|
|
168 |
LOGGER.info("end {}", size);
|
|
|
169 |
|
|
|
170 |
}
|
|
|
171 |
|
|
|
172 |
} else {
|
|
|
173 |
|
|
|
174 |
model.addAttribute("notificationData", notificationData);
|
|
|
175 |
model.addAttribute("size", size);
|
|
|
176 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
177 |
|
|
|
178 |
}
|
| 23923 |
amit.gupta |
179 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
180 |
walletAmount = walletService.getUserWallet(loginDetails.getFofoId()).getAmount();
|
|
|
181 |
inStockAmount = inventoryService.getTotalAmountInStock(loginDetails.getFofoId());
|
| 24312 |
amit.gupta |
182 |
|
| 23884 |
amit.gupta |
183 |
List<Order> unbilledOrders = transactionService.getInTransitOrders(loginDetails.getFofoId());
|
| 23923 |
amit.gupta |
184 |
for (Order unBilledOrder : unbilledOrders) {
|
| 23884 |
amit.gupta |
185 |
unbilledStockAmount += unBilledOrder.getTotalAmount();
|
|
|
186 |
}
|
|
|
187 |
|
| 23904 |
amit.gupta |
188 |
List<Order> grnPendingOrders = orderRepository.selectPendingGrnOrders(loginDetails.getFofoId());
|
| 23923 |
amit.gupta |
189 |
for (Order grnPendingOrder : grnPendingOrders) {
|
| 23884 |
amit.gupta |
190 |
grnPendingStockAmount += grnPendingOrder.getTotalAmount();
|
|
|
191 |
}
|
| 24271 |
amit.gupta |
192 |
totalInvestedAmount = walletAmount + inStockAmount + unbilledStockAmount + grnPendingStockAmount + sale;
|
| 23923 |
amit.gupta |
193 |
shortPercentage = ((fofoStore.getMinimumInvestment() - totalInvestedAmount)
|
|
|
194 |
/ fofoStore.getMinimumInvestment()) * 100;
|
| 23944 |
amit.gupta |
195 |
model.addAttribute("showAlert", shortPercentage > 10);
|
| 23936 |
tejbeer |
196 |
minimumInvestment = fofoStore.getMinimumInvestment();
|
| 24263 |
tejbeer |
197 |
|
|
|
198 |
// debitNoteRepository.se
|
|
|
199 |
List<NotificationData> notificationData = null;
|
|
|
200 |
long size = 0;
|
|
|
201 |
|
|
|
202 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
203 |
size = notificationPanelRepository.selectCountByActiveFlag(true);
|
|
|
204 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
205 |
|
|
|
206 |
LOGGER.info("notification_data {}", size);
|
|
|
207 |
|
|
|
208 |
if (!notificationData.isEmpty()) {
|
|
|
209 |
|
|
|
210 |
model.addAttribute("notificationData", notificationData);
|
|
|
211 |
LOGGER.info("notificationdata", notificationData);
|
|
|
212 |
model.addAttribute("start", offset + 1);
|
|
|
213 |
model.addAttribute("size", size);
|
|
|
214 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
215 |
|
|
|
216 |
LOGGER.info("start {}", offset + 1);
|
|
|
217 |
LOGGER.info("SIZE {}", size);
|
|
|
218 |
|
|
|
219 |
if (notificationData.size() < limit) {
|
|
|
220 |
model.addAttribute("end", offset + notificationData.size());
|
|
|
221 |
LOGGER.info("SIZE2 {}", offset + notificationData.size());
|
|
|
222 |
} else {
|
|
|
223 |
model.addAttribute("end", offset + limit);
|
|
|
224 |
|
|
|
225 |
LOGGER.info("end {}", size);
|
|
|
226 |
|
|
|
227 |
}
|
|
|
228 |
|
|
|
229 |
} else {
|
|
|
230 |
|
|
|
231 |
model.addAttribute("notificationData", notificationData);
|
|
|
232 |
model.addAttribute("size", size);
|
|
|
233 |
LOGGER.info("sizeOriginal {}", size);
|
|
|
234 |
|
|
|
235 |
}
|
| 23884 |
amit.gupta |
236 |
}
|
| 24288 |
amit.gupta |
237 |
LocalDate endDate = LocalDate.now().minusDays(1);
|
|
|
238 |
LocalDate weekStartDate = endDate.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
|
| 24312 |
amit.gupta |
239 |
LocalDate startDate = weekStartDate.minusWeeks(5);
|
|
|
240 |
List<PartnerDailyInvestment> partnerInvestments = partnerDailyInvestmentRepository
|
|
|
241 |
.selectAll(loginDetails.getFofoId(), startDate, endDate);
|
|
|
242 |
|
|
|
243 |
model.addAttribute("investmentChart", this.getInvestmentChartData(partnerInvestments));
|
| 24271 |
amit.gupta |
244 |
model.addAttribute("sale", sale);
|
| 23923 |
amit.gupta |
245 |
model.addAttribute("walletAmount", walletAmount);
|
|
|
246 |
model.addAttribute("inStockAmount", inStockAmount);
|
|
|
247 |
model.addAttribute("unbilledStockAmount", unbilledStockAmount);
|
|
|
248 |
model.addAttribute("grnPendingStockAmount", grnPendingStockAmount);
|
|
|
249 |
model.addAttribute("shortPercentage", shortPercentage);
|
|
|
250 |
model.addAttribute("totalInvestedAmount", totalInvestedAmount);
|
| 23936 |
tejbeer |
251 |
model.addAttribute("minimumInvestmentAmount", minimumInvestment);
|
| 23951 |
amit.gupta |
252 |
model.addAttribute("returnedStockInTransit", returnedStockInTransit);
|
| 23923 |
amit.gupta |
253 |
|
| 23848 |
ashik.ali |
254 |
model.addAttribute("fofoStore", fofoStore);
|
| 23918 |
amit.gupta |
255 |
model.addAttribute("walletAmount");
|
| 22086 |
amit.gupta |
256 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 23796 |
amit.gupta |
257 |
model.addAttribute("isAdmin", roleManager.isAdmin(loginDetails.getRoleIds()));
|
| 23379 |
ashik.ali |
258 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
259 |
model.addAttribute("webApiPort", webApiPort);
|
| 24072 |
amit.gupta |
260 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 24077 |
amit.gupta |
261 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 24203 |
amit.gupta |
262 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
263 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 24248 |
govind |
264 |
model.addAttribute("sale", sale);
|
| 24098 |
tejbeer |
265 |
|
| 23923 |
amit.gupta |
266 |
// LOGGER.info("loginDetails.getFofoId()"+loginDetails.getFofoId());
|
|
|
267 |
// inventoryService.prebookingAvailabilitySendMessage(loginDetails.getFofoId());
|
| 21615 |
kshitij.so |
268 |
return "dashboard";
|
|
|
269 |
}
|
| 23923 |
amit.gupta |
270 |
|
| 24312 |
amit.gupta |
271 |
private String getInvestmentChartData(List<PartnerDailyInvestment> partnerInvestments) {
|
| 24321 |
amit.gupta |
272 |
|
|
|
273 |
|
|
|
274 |
JSONObject scale = new JSONObject().put("scaleLabel", new JSONObject().put("scaleLabel", "Amount in Rs"));
|
|
|
275 |
JSONObject titleObject = new JSONObject()
|
|
|
276 |
.put("display", true)
|
|
|
277 |
.put("text", "Investment Overview").put("display", true);
|
|
|
278 |
|
|
|
279 |
JSONObject barData = new JSONObject();
|
|
|
280 |
|
|
|
281 |
JSONObject walletStack = new JSONObject().put("label", "Wallet").put("backgroundColor","rgba(255, 99, 132, 0.2)")
|
| 24323 |
amit.gupta |
282 |
.put("label", "Wallet").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
283 |
JSONObject inStockStack = new JSONObject().put("label", "In Stock").put("backgroundColor","rgba(54, 162, 235, 0.2)")
|
| 24323 |
amit.gupta |
284 |
.put("label", "In Stock").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
285 |
JSONObject salesStack = new JSONObject().put("label", "Sales").put("backgroundColor","rgba(255, 206, 86, 0.2)")
|
| 24323 |
amit.gupta |
286 |
.put("label", "Sales").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
287 |
JSONObject grnPendingStack = new JSONObject().put("label", "Grn Pending").put("backgroundColor","rgba(75, 192, 192, 0.2)")
|
| 24323 |
amit.gupta |
288 |
.put("label", "Grn Pending").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
289 |
JSONObject billingPendingStack = new JSONObject().put("label", "Billing Pending").put("backgroundColor","rgba(153, 102, 255, 0.2)")
|
| 24323 |
amit.gupta |
290 |
.put("label", "Billing Pending").put("stack", "Stack1").put("data", new JSONArray());
|
|
|
291 |
JSONObject inTransitStack = new JSONObject().put("label", "Stack1").put("backgroundColor","rgba(255, 159, 64, 0.2)")
|
| 24324 |
amit.gupta |
292 |
.put("label", "Returned").put("stack", "Stack1").put("data", new JSONArray());
|
| 24321 |
amit.gupta |
293 |
|
|
|
294 |
JSONArray dateLabels = new JSONArray();
|
|
|
295 |
|
| 24312 |
amit.gupta |
296 |
for (PartnerDailyInvestment pdi : partnerInvestments) {
|
| 24321 |
amit.gupta |
297 |
dateLabels = dateLabels.put(pdi.getDate().toString());
|
|
|
298 |
walletStack.getJSONArray("data").put((int)pdi.getWalletAmount());
|
|
|
299 |
inStockStack.getJSONArray("data").put((int)pdi.getInStockAmount());
|
|
|
300 |
salesStack.getJSONArray("data").put((int)pdi.getSalesAmount());
|
|
|
301 |
grnPendingStack.getJSONArray("data").put((int)pdi.getUnbilledAmount());
|
|
|
302 |
billingPendingStack.getJSONArray("data").put((int)pdi.getGrnPendingAmount());
|
|
|
303 |
inTransitStack.getJSONArray("data").put((int)pdi.getReturnInTransitAmount());
|
| 24312 |
amit.gupta |
304 |
}
|
|
|
305 |
|
| 24321 |
amit.gupta |
306 |
JSONArray barDataSetsArray = new JSONArray().put(walletStack).put(inStockStack)
|
|
|
307 |
.put(salesStack).put(grnPendingStack).put(billingPendingStack).put(inTransitStack);
|
|
|
308 |
barData.put("labels", dateLabels).put("datasets", barDataSetsArray);
|
|
|
309 |
scale.put("yAxes", new JSONArray().put(new JSONObject().put("stacked", true)))
|
|
|
310 |
.put("xAxes", new JSONArray().put(new JSONObject().put("stacked", true)));
|
|
|
311 |
|
|
|
312 |
JSONObject barOptions = new JSONObject()
|
| 24324 |
amit.gupta |
313 |
.put("title", titleObject).put("responsive", true).put("scales", scale)
|
| 24321 |
amit.gupta |
314 |
.put("tooltips", new JSONObject().put("mode", "index").put("intersect", false));
|
|
|
315 |
|
|
|
316 |
JSONObject chartJSOn = new JSONObject().put("type", "bar").put("data", barData).put("options", barOptions);
|
|
|
317 |
return chartJSOn.toString();
|
| 24312 |
amit.gupta |
318 |
}
|
|
|
319 |
|
| 24288 |
amit.gupta |
320 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
321 |
private boolean hasGift(int fofoId) {
|
|
|
322 |
try {
|
| 24288 |
amit.gupta |
323 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
324 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
325 |
} catch (ProfitMandiBusinessException e) {
|
|
|
326 |
return false;
|
|
|
327 |
}
|
|
|
328 |
}
|
| 24288 |
amit.gupta |
329 |
|
| 24098 |
tejbeer |
330 |
@RequestMapping(value = "/getPaginatedNotificationData", method = RequestMethod.GET)
|
|
|
331 |
public String getPaginatedNotificationData(HttpServletRequest request,
|
|
|
332 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
333 |
@RequestParam(name = "limit", defaultValue = "10") int limit, Model model) throws Exception {
|
| 24263 |
tejbeer |
334 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 24098 |
tejbeer |
335 |
|
| 24263 |
tejbeer |
336 |
if (roleManager.isAdmin(loginDetails.getRoleIds())) {
|
|
|
337 |
List<NotificationData> notificationData = null;
|
| 24098 |
tejbeer |
338 |
|
| 24263 |
tejbeer |
339 |
notificationData = notificationPanelRepository.selectAllNotificationData(offset, limit);
|
| 24098 |
tejbeer |
340 |
|
| 24263 |
tejbeer |
341 |
LOGGER.info("notification_data {}", notificationData);
|
| 24098 |
tejbeer |
342 |
|
| 24263 |
tejbeer |
343 |
if (!notificationData.isEmpty()) {
|
| 24098 |
tejbeer |
344 |
|
| 24263 |
tejbeer |
345 |
model.addAttribute("notificationData", notificationData);
|
|
|
346 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
347 |
|
|
|
348 |
} else {
|
|
|
349 |
model.addAttribute("notificationData", notificationData);
|
|
|
350 |
|
|
|
351 |
}
|
|
|
352 |
} else if (roleManager.isPartner(loginDetails.getRoleIds())) {
|
|
|
353 |
|
|
|
354 |
List<NotificationData> notificationData = null;
|
|
|
355 |
|
|
|
356 |
notificationData = notificationPanelRepository.selectAllNotificationDataByActiveFlag(offset, limit, true);
|
|
|
357 |
LOGGER.info("notification_data {}", notificationData);
|
|
|
358 |
|
|
|
359 |
if (!notificationData.isEmpty()) {
|
|
|
360 |
|
|
|
361 |
model.addAttribute("notificationData", notificationData);
|
|
|
362 |
model.addAttribute("url", "/getPaginatedNotificationData");
|
|
|
363 |
|
|
|
364 |
} else {
|
|
|
365 |
model.addAttribute("notificationData", notificationData);
|
|
|
366 |
|
|
|
367 |
}
|
| 24098 |
tejbeer |
368 |
}
|
|
|
369 |
|
|
|
370 |
return "dashboard-paginated";
|
|
|
371 |
}
|
| 24288 |
amit.gupta |
372 |
|
| 22354 |
ashik.ali |
373 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
374 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
375 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
376 |
return "contact-us";
|
|
|
377 |
}
|
| 23923 |
amit.gupta |
378 |
|
|
|
379 |
/*
|
|
|
380 |
* private List<PaymentOption> getPaymentOptions(int fofoId){ List<Integer>
|
|
|
381 |
* paymentOptionIds =
|
| 24288 |
amit.gupta |
382 |
* fofoPartnerPaymentOptionRepository.selectPaymentOptionIdsByFofoId(fofoId) ;
|
|
|
383 |
* if(paymentOptionIds.isEmpty()){ return new ArrayList<>(); } return
|
| 23923 |
amit.gupta |
384 |
* paymentOptionRepository.selectByIds(new HashSet<>(paymentOptionIds)); }
|
|
|
385 |
*/
|
|
|
386 |
|
| 24263 |
tejbeer |
387 |
@RequestMapping(value = "/inactiveNotificationData", method = RequestMethod.POST)
|
|
|
388 |
public String inactiveNotificationData(HttpServletRequest request,
|
|
|
389 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
390 |
|
|
|
391 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
392 |
if (notificationData != null) {
|
|
|
393 |
|
|
|
394 |
notificationData.setActive(false);
|
|
|
395 |
LOGGER.info("notification" + notificationData);
|
|
|
396 |
notificationPanelRepository.persist(notificationData);
|
|
|
397 |
|
|
|
398 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
399 |
} else {
|
|
|
400 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
401 |
|
|
|
402 |
}
|
|
|
403 |
return "response";
|
|
|
404 |
}
|
|
|
405 |
|
|
|
406 |
@RequestMapping(value = "/activeNotificationData", method = RequestMethod.POST)
|
|
|
407 |
public String activeNotificationData(HttpServletRequest request,
|
|
|
408 |
@RequestParam(name = "id", defaultValue = "0") int id, Model model) throws Exception {
|
|
|
409 |
|
|
|
410 |
NotificationData notificationData = notificationPanelRepository.selectById(id);
|
|
|
411 |
if (notificationData != null) {
|
|
|
412 |
|
|
|
413 |
notificationData.setActive(true);
|
|
|
414 |
notificationData.setCreated_timestamp(LocalDateTime.now());
|
|
|
415 |
LOGGER.info("notification" + notificationData);
|
|
|
416 |
notificationPanelRepository.persist(notificationData);
|
|
|
417 |
|
|
|
418 |
model.addAttribute("response", mvcResponseSender.createResponseString(true));
|
|
|
419 |
} else {
|
|
|
420 |
model.addAttribute("response", mvcResponseSender.createResponseString(false));
|
|
|
421 |
|
|
|
422 |
}
|
|
|
423 |
return "response";
|
|
|
424 |
}
|
|
|
425 |
|
| 21615 |
kshitij.so |
426 |
}
|