| 21615 |
kshitij.so |
1 |
package com.spice.profitmandi.web.controller;
|
|
|
2 |
|
| 25221 |
amit.gupta |
3 |
import java.text.DecimalFormat;
|
| 24288 |
amit.gupta |
4 |
import java.time.LocalDate;
|
| 24276 |
amit.gupta |
5 |
import java.time.LocalDateTime;
|
| 24880 |
govind |
6 |
import java.time.LocalTime;
|
| 25649 |
tejbeer |
7 |
import java.time.ZoneOffset;
|
| 24339 |
amit.gupta |
8 |
import java.util.ArrayList;
|
| 25136 |
amit.gupta |
9 |
import java.util.LinkedHashMap;
|
| 23884 |
amit.gupta |
10 |
import java.util.List;
|
| 24880 |
govind |
11 |
import java.util.Map;
|
|
|
12 |
import java.util.stream.Collectors;
|
| 23568 |
govind |
13 |
|
| 22086 |
amit.gupta |
14 |
import javax.servlet.http.HttpServletRequest;
|
| 25221 |
amit.gupta |
15 |
import javax.transaction.Transactional;
|
| 22086 |
amit.gupta |
16 |
|
| 23786 |
amit.gupta |
17 |
import org.apache.logging.log4j.LogManager;
|
| 23568 |
govind |
18 |
import org.apache.logging.log4j.Logger;
|
| 22481 |
ashik.ali |
19 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 23379 |
ashik.ali |
20 |
import org.springframework.beans.factory.annotation.Value;
|
| 25649 |
tejbeer |
21 |
import org.springframework.http.MediaType;
|
|
|
22 |
import org.springframework.http.ResponseEntity;
|
| 21615 |
kshitij.so |
23 |
import org.springframework.stereotype.Controller;
|
| 22073 |
ashik.ali |
24 |
import org.springframework.ui.Model;
|
| 21615 |
kshitij.so |
25 |
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
26 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| 25649 |
tejbeer |
27 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 21615 |
kshitij.so |
28 |
|
| 25649 |
tejbeer |
29 |
import com.google.gson.Gson;
|
| 24996 |
amit.gupta |
30 |
import com.mongodb.DBObject;
|
| 22481 |
ashik.ali |
31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 24996 |
amit.gupta |
32 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| 25649 |
tejbeer |
33 |
import com.spice.profitmandi.common.model.Notification;
|
| 24203 |
amit.gupta |
34 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| 25649 |
tejbeer |
35 |
import com.spice.profitmandi.common.model.SendNotificationModel;
|
|
|
36 |
import com.spice.profitmandi.dao.Interface.Campaign;
|
|
|
37 |
import com.spice.profitmandi.dao.entity.dtr.NotificationCampaign;
|
|
|
38 |
import com.spice.profitmandi.dao.entity.dtr.UserCampaign;
|
| 24880 |
govind |
39 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 22654 |
ashik.ali |
40 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| 25649 |
tejbeer |
41 |
import com.spice.profitmandi.dao.entity.fofo.HygieneData;
|
| 24288 |
amit.gupta |
42 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 25214 |
amit.gupta |
43 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTarget;
|
|
|
44 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 25566 |
tejbeer |
45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| 25649 |
tejbeer |
46 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
|
|
47 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 24880 |
govind |
48 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 22481 |
ashik.ali |
49 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 24880 |
govind |
50 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
|
|
51 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 24996 |
amit.gupta |
52 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| 25649 |
tejbeer |
53 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 24098 |
tejbeer |
54 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 24880 |
govind |
55 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| 25649 |
tejbeer |
56 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
|
|
57 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 24203 |
amit.gupta |
58 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 24880 |
govind |
59 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| 25649 |
tejbeer |
60 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 24288 |
amit.gupta |
61 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 25214 |
amit.gupta |
62 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 25566 |
tejbeer |
63 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 25214 |
amit.gupta |
64 |
import com.spice.profitmandi.dao.repository.fofo.TargetSlabRepository;
|
| 25649 |
tejbeer |
65 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 24336 |
amit.gupta |
66 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 23844 |
amit.gupta |
67 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 23884 |
amit.gupta |
68 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 25214 |
amit.gupta |
69 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
| 23884 |
amit.gupta |
70 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| 22481 |
ashik.ali |
71 |
import com.spice.profitmandi.web.model.LoginDetails;
|
|
|
72 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 24263 |
tejbeer |
73 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| 22481 |
ashik.ali |
74 |
|
| 21615 |
kshitij.so |
75 |
@Controller
|
| 25222 |
amit.gupta |
76 |
@Transactional(rollbackOn = Throwable.class)
|
| 21615 |
kshitij.so |
77 |
public class DashboardController {
|
| 23923 |
amit.gupta |
78 |
|
| 23379 |
ashik.ali |
79 |
@Value("${web.api.host}")
|
|
|
80 |
private String webApiHost;
|
| 23923 |
amit.gupta |
81 |
|
| 24072 |
amit.gupta |
82 |
@Value("${web.api.scheme}")
|
|
|
83 |
private String webApiScheme;
|
| 24288 |
amit.gupta |
84 |
|
| 24078 |
amit.gupta |
85 |
@Value("${web.api.root}")
|
|
|
86 |
private String webApiRoot;
|
|
|
87 |
|
| 23379 |
ashik.ali |
88 |
@Value("${web.api.port}")
|
|
|
89 |
private int webApiPort;
|
| 21615 |
kshitij.so |
90 |
|
| 22481 |
ashik.ali |
91 |
@Autowired
|
| 22927 |
ashik.ali |
92 |
private CookiesProcessor cookiesProcessor;
|
| 23923 |
amit.gupta |
93 |
|
| 23568 |
govind |
94 |
@Autowired
|
| 24880 |
govind |
95 |
private ItemRepository itemRepository;
|
|
|
96 |
|
|
|
97 |
@Autowired
|
| 25214 |
amit.gupta |
98 |
private TargetSlabService targetSlabService;
|
|
|
99 |
|
|
|
100 |
@Autowired
|
|
|
101 |
private PartnerTargetRepository partnerTargetRepository;
|
|
|
102 |
|
|
|
103 |
@Autowired
|
|
|
104 |
private TargetSlabRepository targetSlabRepository;
|
|
|
105 |
|
|
|
106 |
@Autowired
|
| 23786 |
amit.gupta |
107 |
private RoleManager roleManager;
|
| 23923 |
amit.gupta |
108 |
|
| 23838 |
ashik.ali |
109 |
@Autowired
|
|
|
110 |
private FofoStoreRepository fofoStoreRepository;
|
| 23884 |
amit.gupta |
111 |
|
|
|
112 |
@Autowired
|
| 24880 |
govind |
113 |
private PartnerDailyInvestmentRepository partnerDailyInvestmentRepository;
|
| 23923 |
amit.gupta |
114 |
|
| 23884 |
amit.gupta |
115 |
@Autowired
|
| 24880 |
govind |
116 |
private PartnerInvestmentService partnerInvestmentService;
|
| 24288 |
amit.gupta |
117 |
|
| 23884 |
amit.gupta |
118 |
@Autowired
|
| 24880 |
govind |
119 |
private InsurancePolicyRepository insurancePolicyRepository;
|
| 23923 |
amit.gupta |
120 |
/*
|
|
|
121 |
* @Autowired private ScanRepository scanRepository;
|
|
|
122 |
*/
|
| 24880 |
govind |
123 |
@Autowired
|
|
|
124 |
private RechargeTransactionRepository rechargeTransactionRepository;
|
| 23923 |
amit.gupta |
125 |
|
| 23884 |
amit.gupta |
126 |
@Autowired
|
|
|
127 |
private TransactionService transactionService;
|
| 25136 |
amit.gupta |
128 |
|
| 24996 |
amit.gupta |
129 |
@Autowired
|
|
|
130 |
private InventoryService inventoryService;
|
| 24263 |
tejbeer |
131 |
|
| 24098 |
tejbeer |
132 |
@Autowired
|
| 24263 |
tejbeer |
133 |
private MVCResponseSender mvcResponseSender;
|
|
|
134 |
|
|
|
135 |
@Autowired
|
| 24098 |
tejbeer |
136 |
private NotificationPanelRepository notificationPanelRepository;
|
| 23923 |
amit.gupta |
137 |
|
| 24203 |
amit.gupta |
138 |
@Autowired
|
|
|
139 |
private CurrentInventorySnapshotRepository currentInventorySnapshotRepository;
|
|
|
140 |
|
| 24880 |
govind |
141 |
@Autowired
|
|
|
142 |
private FofoOrderItemRepository fofoOrderItemRepository;
|
|
|
143 |
|
|
|
144 |
@Autowired
|
|
|
145 |
private InsuranceProviderRepository insuranceProviderRepository;
|
| 25566 |
tejbeer |
146 |
@Autowired
|
|
|
147 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 25136 |
amit.gupta |
148 |
|
| 24996 |
amit.gupta |
149 |
@Autowired
|
| 25649 |
tejbeer |
150 |
private HygieneDataRepository hygieneDataRepository;
|
|
|
151 |
|
|
|
152 |
@Autowired
|
|
|
153 |
private UserCampaignRepository userCampaignRepository;
|
|
|
154 |
|
|
|
155 |
@Autowired
|
|
|
156 |
private UserAccountRepository userAccountRepository;
|
|
|
157 |
|
|
|
158 |
@Autowired
|
|
|
159 |
private NotificationCampaignRepository notificationCampaignRepository;
|
|
|
160 |
|
|
|
161 |
@Autowired
|
| 24996 |
amit.gupta |
162 |
private Mongo mongoClient;
|
| 24880 |
govind |
163 |
|
| 25649 |
tejbeer |
164 |
@Autowired
|
|
|
165 |
private Gson gson;
|
|
|
166 |
|
| 23568 |
govind |
167 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 23923 |
amit.gupta |
168 |
|
| 25136 |
amit.gupta |
169 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 25140 |
amit.gupta |
170 |
public String dashboard1(HttpServletRequest request, Model model) throws Exception {
|
| 25136 |
amit.gupta |
171 |
LOGGER.info("In Dashboard1");
|
|
|
172 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 25179 |
amit.gupta |
173 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
174 |
model.addAttribute("isAdmin", isAdmin);
|
| 25180 |
amit.gupta |
175 |
if (!isAdmin) {
|
| 25649 |
tejbeer |
176 |
// model.addAttribute("brandStockPrices",
|
|
|
177 |
// this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 25179 |
amit.gupta |
178 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
|
|
179 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
|
|
180 |
return "dashboard1";
|
|
|
181 |
}
|
| 25136 |
amit.gupta |
182 |
return "dashboard1";
|
|
|
183 |
}
|
|
|
184 |
|
|
|
185 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
|
|
186 |
Map<String, Object> investments = new LinkedHashMap<>();
|
|
|
187 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| 25649 |
tejbeer |
188 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
| 25136 |
amit.gupta |
189 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
|
|
190 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
|
|
191 |
if (yesterdayInvestment == null) {
|
|
|
192 |
yesterdayInvestment = new PartnerDailyInvestment();
|
|
|
193 |
}
|
|
|
194 |
|
|
|
195 |
List<PartnerDailyInvestment> currentMonthInvestments = partnerDailyInvestmentRepository.selectAll(fofoId,
|
|
|
196 |
currentMonthStart, currentMonthStart.withDayOfMonth(currentMonthStart.lengthOfMonth()));
|
|
|
197 |
|
| 25140 |
amit.gupta |
198 |
long okInvestmentDays = currentMonthInvestments.stream().filter(x -> x.getShortPercentage() <= 10)
|
| 25136 |
amit.gupta |
199 |
.collect(Collectors.counting());
|
| 25140 |
amit.gupta |
200 |
investments.put("today", investment.getTotalInvestment());
|
|
|
201 |
investments.put("investment", investment);
|
|
|
202 |
investments.put("inStock", investment.getInStockAmount());
|
| 25182 |
amit.gupta |
203 |
investments.put("minimum", investment.getMinInvestmentString());
|
| 25140 |
amit.gupta |
204 |
investments.put("short", investment.getShortPercentage());
|
| 25649 |
tejbeer |
205 |
investments.put("okDays", okInvestmentDays);
|
| 25136 |
amit.gupta |
206 |
return investments;
|
|
|
207 |
}
|
|
|
208 |
|
| 25221 |
amit.gupta |
209 |
private Map<String, Object> getSales(int fofoId) {
|
|
|
210 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| 25140 |
amit.gupta |
211 |
LocalDateTime curDate = LocalDate.now().atStartOfDay();
|
| 25214 |
amit.gupta |
212 |
int monthLength = LocalDate.now().lengthOfMonth();
|
| 25140 |
amit.gupta |
213 |
List<FofoOrderItem> fofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId, curDate,
|
|
|
214 |
curDate.with(LocalTime.MAX));
|
|
|
215 |
List<FofoOrderItem> mtdFofoOrderItems = fofoOrderItemRepository.selectBetweenCreatedTime(fofoId,
|
|
|
216 |
curDate.withDayOfMonth(1), curDate.with(LocalTime.MAX));
|
|
|
217 |
double todaySale = fofoOrderItems.stream()
|
|
|
218 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
|
|
219 |
double mtdSale = mtdFofoOrderItems.stream()
|
|
|
220 |
.collect(Collectors.summingDouble(x -> x.getSellingPrice() * x.getQuantity()));
|
| 25214 |
amit.gupta |
221 |
|
|
|
222 |
List<PartnerTargetDetails> partnerTargetDetails = partnerTargetRepository
|
|
|
223 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now());
|
| 25544 |
amit.gupta |
224 |
if (partnerTargetDetails.isEmpty()) {
|
| 25372 |
tejbeer |
225 |
partnerTargetDetails = partnerTargetRepository
|
| 25633 |
amit.gupta |
226 |
.selectAllGeEqAndLeEqStartDateAndEndDate(LocalDateTime.now().minusMonths(2));
|
| 25372 |
tejbeer |
227 |
}
|
| 25214 |
amit.gupta |
228 |
|
|
|
229 |
List<Integer> targetIds = partnerTargetRepository
|
|
|
230 |
.selectAllPartnerTargetForPartner(fofoId,
|
|
|
231 |
partnerTargetDetails.stream().map(x -> x.getId()).collect(Collectors.toList()))
|
|
|
232 |
.stream().map(x -> x.getTargetId()).collect(Collectors.toList());
|
|
|
233 |
if (targetIds.size() > 0) {
|
|
|
234 |
PartnerTarget target = partnerTargetRepository.selectAllPartnerTargetForPartner(fofoId, targetIds).get(0);
|
| 25544 |
amit.gupta |
235 |
double targetValue = (double) target.getTargetValue();
|
| 25214 |
amit.gupta |
236 |
int remainingDays = monthLength - curDate.getDayOfMonth() + 1;
|
| 25544 |
amit.gupta |
237 |
// Should not consider today's sale while evaluating today's target.
|
|
|
238 |
double todayTargetValue = Math.round((targetValue - (mtdSale - todaySale)) / remainingDays);
|
| 25221 |
amit.gupta |
239 |
DecimalFormat df = new DecimalFormat("#.##");
|
| 25544 |
amit.gupta |
240 |
String targetValueString = df.format(targetValue / 100000) + "Lac";
|
| 25214 |
amit.gupta |
241 |
salesMap.put("todayTarget", todayTargetValue);
|
| 25223 |
amit.gupta |
242 |
salesMap.put("monthTarget", targetValueString);
|
| 25214 |
amit.gupta |
243 |
} else {
|
|
|
244 |
salesMap.put("todayTarget", 0d);
|
|
|
245 |
salesMap.put("monthTarget", 0d);
|
|
|
246 |
|
|
|
247 |
}
|
| 25140 |
amit.gupta |
248 |
salesMap.put("todaySale", todaySale);
|
|
|
249 |
salesMap.put("mtdSale", mtdSale);
|
| 25136 |
amit.gupta |
250 |
return salesMap;
|
|
|
251 |
}
|
|
|
252 |
|
| 25649 |
tejbeer |
253 |
/*
|
|
|
254 |
* private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws
|
|
|
255 |
* Exception { Map<String, BrandStockPrice> brandStockPricesMap =
|
|
|
256 |
* inventoryService.getBrandWiseStockValue(fofoId);
|
|
|
257 |
*
|
|
|
258 |
* List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
|
|
259 |
* List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
|
|
260 |
*
|
|
|
261 |
* mobileBrands.stream().forEach(x -> { String brand = (String) x.get("name");
|
|
|
262 |
* if (brandStockPricesMap.containsKey(brand)) { BrandStockPrice brandStockPrice
|
|
|
263 |
* = brandStockPricesMap.get(brand); brandStockPrice.setBrandUrl((String)
|
|
|
264 |
* x.get("url")); brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
|
|
265 |
* brandStockPrices.add(brandStockPrice); } });
|
|
|
266 |
*
|
|
|
267 |
* return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x,
|
|
|
268 |
* y) -> x.getRank() - y.getRank()) .collect(Collectors.toList()); }
|
|
|
269 |
*/
|
| 25175 |
amit.gupta |
270 |
|
| 21615 |
kshitij.so |
271 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 25649 |
tejbeer |
272 |
public String dashboard(HttpServletRequest request, @RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
273 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
| 25140 |
amit.gupta |
274 |
|
| 22927 |
ashik.ali |
275 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 25180 |
amit.gupta |
276 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
|
|
277 |
model.addAttribute("isAdmin", isAdmin);
|
| 23923 |
amit.gupta |
278 |
|
| 22481 |
ashik.ali |
279 |
FofoStore fofoStore = null;
|
| 25274 |
amit.gupta |
280 |
model.addAttribute("webApiHost", webApiHost);
|
|
|
281 |
model.addAttribute("webApiPort", webApiPort);
|
|
|
282 |
model.addAttribute("webApiScheme", webApiScheme);
|
| 25544 |
amit.gupta |
283 |
model.addAttribute("webApiRoot", webApiRoot);
|
| 25183 |
amit.gupta |
284 |
if (isAdmin) {
|
| 25180 |
amit.gupta |
285 |
return "dashboard1";
|
|
|
286 |
} else {
|
|
|
287 |
try {
|
|
|
288 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 25566 |
tejbeer |
289 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| 25544 |
amit.gupta |
290 |
if (!fofoStore.isActive()) {
|
|
|
291 |
return "redirect:/login";
|
|
|
292 |
}
|
| 25649 |
tejbeer |
293 |
|
| 25566 |
tejbeer |
294 |
LOGGER.info("partnerType {}", partnerType);
|
|
|
295 |
|
|
|
296 |
model.addAttribute("partnerType", partnerType);
|
| 25180 |
amit.gupta |
297 |
model.addAttribute("fofoStore", fofoStore);
|
| 25566 |
tejbeer |
298 |
model.addAttribute("partnerType", partnerType);
|
| 25180 |
amit.gupta |
299 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
|
|
300 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
|
|
301 |
|
| 25649 |
tejbeer |
302 |
// model.addAttribute("brandStockPrices",
|
|
|
303 |
// this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 25180 |
amit.gupta |
304 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 25544 |
amit.gupta |
305 |
// this.setInvestments
|
|
|
306 |
//
|
| 25180 |
amit.gupta |
307 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 25544 |
amit.gupta |
308 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
|
|
309 |
10, ProfitMandiConstants.CUTOFF_INVESTMENT));
|
| 25180 |
amit.gupta |
310 |
} catch (ProfitMandiBusinessException e) {
|
|
|
311 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
|
|
312 |
|
|
|
313 |
}
|
| 22481 |
ashik.ali |
314 |
}
|
| 25649 |
tejbeer |
315 |
|
|
|
316 |
LocalDateTime currentMonthStart = LocalDateTime.now().withDayOfMonth(1);
|
|
|
317 |
List<HygieneData> hygieneData = hygieneDataRepository
|
|
|
318 |
.selectAll(loginDetails.getFofoId(), currentMonthStart,
|
|
|
319 |
LocalDateTime.now().plusMonths(1).withDayOfMonth(1))
|
|
|
320 |
.stream().filter(x -> x.getDisposedTimestamp() != null).collect(Collectors.toList());
|
|
|
321 |
|
|
|
322 |
LOGGER.info("hygieneData" + hygieneData);
|
|
|
323 |
int successHygieneData = hygieneData.stream().filter(x -> x.getHygieneRating() == true)
|
|
|
324 |
.collect(Collectors.toList()).size();
|
|
|
325 |
int unsuccessfullHygieneData = hygieneData.stream().filter(x -> x.getHygieneRating() == false)
|
|
|
326 |
.collect(Collectors.toList()).size();
|
|
|
327 |
|
|
|
328 |
model.addAttribute("successHygieneData", successHygieneData);
|
|
|
329 |
model.addAttribute("fullHygieneData", successHygieneData + unsuccessfullHygieneData);
|
|
|
330 |
|
| 25197 |
amit.gupta |
331 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
|
|
332 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 25140 |
amit.gupta |
333 |
return "dashboard1";
|
| 21615 |
kshitij.so |
334 |
}
|
| 23923 |
amit.gupta |
335 |
|
| 24288 |
amit.gupta |
336 |
// This method is currently hardcoded to faciliate watches sold as gift.
|
| 24203 |
amit.gupta |
337 |
private boolean hasGift(int fofoId) {
|
|
|
338 |
try {
|
| 24288 |
amit.gupta |
339 |
return currentInventorySnapshotRepository.selectByItemIdAndFofoId(ProfitMandiConstants.GIFT_ID, fofoId)
|
|
|
340 |
.getAvailability() > 0;
|
| 24203 |
amit.gupta |
341 |
} catch (ProfitMandiBusinessException e) {
|
|
|
342 |
return false;
|
|
|
343 |
}
|
|
|
344 |
}
|
| 24288 |
amit.gupta |
345 |
|
| 22354 |
ashik.ali |
346 |
@RequestMapping(value = "/contactUs", method = RequestMethod.GET)
|
| 23923 |
amit.gupta |
347 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 22354 |
ashik.ali |
348 |
model.addAttribute("appContextPath", request.getContextPath());
|
|
|
349 |
return "contact-us";
|
|
|
350 |
}
|
| 23923 |
amit.gupta |
351 |
|
| 25649 |
tejbeer |
352 |
@RequestMapping(value = "/notifications", method = RequestMethod.GET)
|
|
|
353 |
public String getNotificationsWithType(HttpServletRequest request, @RequestParam(value = "") String notifyType,
|
|
|
354 |
@RequestParam(name = "offset", defaultValue = "0") int offset,
|
|
|
355 |
@RequestParam(name = "limit", defaultValue = "20") int limit, Model model) throws Exception {
|
|
|
356 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
|
|
357 |
int userId = userAccountRepository.selectUserIdByRetailerId(loginDetails.getFofoId());
|
|
|
358 |
List<UserCampaign> userCampaigns = userCampaignRepository.selectByUserId(userId);
|
|
|
359 |
List<Notification> notifications = new ArrayList<>();
|
|
|
360 |
if (!userCampaigns.isEmpty()) {
|
|
|
361 |
List<Integer> campaignIds = new ArrayList<>();
|
|
|
362 |
for (UserCampaign userCampaign : userCampaigns) {
|
|
|
363 |
campaignIds.add(userCampaign.getCampaignId());
|
|
|
364 |
}
|
|
|
365 |
List<NotificationCampaign> notificationCampaigns = notificationCampaignRepository.selectbyCids(campaignIds);
|
|
|
366 |
if (notifyType.equals("annoucement")) {
|
|
|
367 |
for (NotificationCampaign notificationCampaign : notificationCampaigns) {
|
|
|
368 |
if (notificationCampaign.isAnnoucement() == true) {
|
|
|
369 |
Notification ns = new Notification();
|
|
|
370 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
371 |
SimpleCampaignParams.class);
|
|
|
372 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
373 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
374 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
375 |
ns.setType(campaign.getType());
|
|
|
376 |
ns.setMessage(campaign.getMessage());
|
|
|
377 |
ns.setTitle(campaign.getTitle());
|
|
|
378 |
ns.setUrl(campaign.getUrl());
|
|
|
379 |
ns.setShowImage(campaign.getShowImage());
|
|
|
380 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
381 |
ns.setAnnoucement(notificationCampaign.isAnnoucement());
|
|
|
382 |
ns.setCreated(notificationCampaign.getCreatedTimestamp()
|
|
|
383 |
.toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)) * 1000);
|
|
|
384 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
385 |
ns.setExpired(true);
|
|
|
386 |
} else {
|
|
|
387 |
ns.setExpired(false);
|
|
|
388 |
}
|
|
|
389 |
notifications.add(ns);
|
|
|
390 |
}
|
|
|
391 |
}
|
|
|
392 |
} else if (notifyType.equals("notification")) {
|
|
|
393 |
for (NotificationCampaign notificationCampaign : notificationCampaigns) {
|
|
|
394 |
if (notificationCampaign.isAnnoucement() == false) {
|
|
|
395 |
Notification ns = new Notification();
|
|
|
396 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
397 |
SimpleCampaignParams.class);
|
|
|
398 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
399 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
400 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
401 |
ns.setType(campaign.getType());
|
|
|
402 |
ns.setMessage(campaign.getMessage());
|
|
|
403 |
ns.setTitle(campaign.getTitle());
|
|
|
404 |
ns.setUrl(campaign.getUrl());
|
|
|
405 |
ns.setShowImage(campaign.getShowImage());
|
|
|
406 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
407 |
ns.setAnnoucement(notificationCampaign.isAnnoucement());
|
|
|
408 |
ns.setCreated(notificationCampaign.getCreatedTimestamp()
|
|
|
409 |
.toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30)) * 1000);
|
|
|
410 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
411 |
ns.setExpired(true);
|
|
|
412 |
} else {
|
|
|
413 |
ns.setExpired(false);
|
|
|
414 |
}
|
|
|
415 |
notifications.add(ns);
|
|
|
416 |
}
|
|
|
417 |
}
|
|
|
418 |
} else {
|
|
|
419 |
for (NotificationCampaign notificationCampaign : notificationCampaigns) {
|
|
|
420 |
Notification ns = new Notification();
|
|
|
421 |
SimpleCampaignParams scp = gson.fromJson(notificationCampaign.getImplementationParams(),
|
|
|
422 |
SimpleCampaignParams.class);
|
|
|
423 |
Campaign campaign = new SimpleCampaign(scp);
|
|
|
424 |
LocalDateTime expire = campaign.getExpireTimestamp();
|
|
|
425 |
ns.setCid(Integer.toString(notificationCampaign.getId()));
|
|
|
426 |
ns.setType(campaign.getType());
|
|
|
427 |
ns.setMessage(campaign.getMessage());
|
|
|
428 |
ns.setTitle(campaign.getTitle());
|
|
|
429 |
ns.setUrl(campaign.getUrl());
|
|
|
430 |
ns.setShowImage(campaign.getShowImage());
|
|
|
431 |
ns.setImageUrl(campaign.getImageUrl());
|
|
|
432 |
ns.setAnnoucement(notificationCampaign.isAnnoucement());
|
|
|
433 |
ns.setCreated(
|
|
|
434 |
notificationCampaign.getCreatedTimestamp().toEpochSecond(ZoneOffset.ofHoursMinutes(5, 30))
|
|
|
435 |
* 1000);
|
|
|
436 |
if (LocalDateTime.now().isAfter(expire)) {
|
|
|
437 |
ns.setExpired(true);
|
|
|
438 |
} else {
|
|
|
439 |
ns.setExpired(false);
|
|
|
440 |
}
|
|
|
441 |
notifications.add(ns);
|
|
|
442 |
}
|
|
|
443 |
}
|
|
|
444 |
}
|
|
|
445 |
|
|
|
446 |
model.addAttribute("notifications", notifications);
|
|
|
447 |
|
|
|
448 |
LOGGER.info("notifications"+notifications);
|
|
|
449 |
return "notification-template" ;
|
|
|
450 |
}
|
|
|
451 |
|
| 21615 |
kshitij.so |
452 |
}
|