| Line 2... |
Line 2... |
| 2 |
|
2 |
|
| 3 |
import java.text.DecimalFormat;
|
3 |
import java.text.DecimalFormat;
|
| 4 |
import java.time.LocalDate;
|
4 |
import java.time.LocalDate;
|
| 5 |
import java.time.LocalDateTime;
|
5 |
import java.time.LocalDateTime;
|
| 6 |
import java.time.LocalTime;
|
6 |
import java.time.LocalTime;
|
| - |
|
7 |
import java.time.ZoneOffset;
|
| 7 |
import java.util.ArrayList;
|
8 |
import java.util.ArrayList;
|
| 8 |
import java.util.LinkedHashMap;
|
9 |
import java.util.LinkedHashMap;
|
| 9 |
import java.util.List;
|
10 |
import java.util.List;
|
| 10 |
import java.util.Map;
|
11 |
import java.util.Map;
|
| 11 |
import java.util.stream.Collectors;
|
12 |
import java.util.stream.Collectors;
|
| Line 15... |
Line 16... |
| 15 |
|
16 |
|
| 16 |
import org.apache.logging.log4j.LogManager;
|
17 |
import org.apache.logging.log4j.LogManager;
|
| 17 |
import org.apache.logging.log4j.Logger;
|
18 |
import org.apache.logging.log4j.Logger;
|
| 18 |
import org.springframework.beans.factory.annotation.Autowired;
|
19 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 19 |
import org.springframework.beans.factory.annotation.Value;
|
20 |
import org.springframework.beans.factory.annotation.Value;
|
| - |
|
21 |
import org.springframework.http.MediaType;
|
| - |
|
22 |
import org.springframework.http.ResponseEntity;
|
| 20 |
import org.springframework.stereotype.Controller;
|
23 |
import org.springframework.stereotype.Controller;
|
| 21 |
import org.springframework.ui.Model;
|
24 |
import org.springframework.ui.Model;
|
| 22 |
import org.springframework.web.bind.annotation.RequestMapping;
|
25 |
import org.springframework.web.bind.annotation.RequestMapping;
|
| 23 |
import org.springframework.web.bind.annotation.RequestMethod;
|
26 |
import org.springframework.web.bind.annotation.RequestMethod;
|
| - |
|
27 |
import org.springframework.web.bind.annotation.RequestParam;
|
| 24 |
|
28 |
|
| - |
|
29 |
import com.google.gson.Gson;
|
| 25 |
import com.mongodb.DBObject;
|
30 |
import com.mongodb.DBObject;
|
| 26 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
31 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 27 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
32 |
import com.spice.profitmandi.common.model.BrandStockPrice;
|
| - |
|
33 |
import com.spice.profitmandi.common.model.Notification;
|
| 28 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
34 |
import com.spice.profitmandi.common.model.ProfitMandiConstants;
|
| - |
|
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;
|
| 29 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
39 |
import com.spice.profitmandi.dao.entity.fofo.FofoOrderItem;
|
| 30 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
40 |
import com.spice.profitmandi.dao.entity.fofo.FofoStore;
|
| - |
|
41 |
import com.spice.profitmandi.dao.entity.fofo.HygieneData;
|
| 31 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
42 |
import com.spice.profitmandi.dao.entity.fofo.PartnerDailyInvestment;
|
| 32 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTarget;
|
43 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTarget;
|
| 33 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
44 |
import com.spice.profitmandi.dao.entity.fofo.PartnerTargetDetails;
|
| 34 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
45 |
import com.spice.profitmandi.dao.entity.fofo.PartnerType;
|
| - |
|
46 |
import com.spice.profitmandi.dao.model.SimpleCampaign;
|
| - |
|
47 |
import com.spice.profitmandi.dao.model.SimpleCampaignParams;
|
| 35 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
48 |
import com.spice.profitmandi.dao.repository.catalog.ItemRepository;
|
| 36 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
49 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| 37 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
50 |
import com.spice.profitmandi.dao.repository.dtr.InsurancePolicyRepository;
|
| 38 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
51 |
import com.spice.profitmandi.dao.repository.dtr.InsuranceProviderRepository;
|
| 39 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
52 |
import com.spice.profitmandi.dao.repository.dtr.Mongo;
|
| - |
|
53 |
import com.spice.profitmandi.dao.repository.dtr.NotificationCampaignRepository;
|
| 40 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
54 |
import com.spice.profitmandi.dao.repository.dtr.NotificationPanelRepository;
|
| 41 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
55 |
import com.spice.profitmandi.dao.repository.dtr.RechargeTransactionRepository;
|
| - |
|
56 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| - |
|
57 |
import com.spice.profitmandi.dao.repository.dtr.UserCampaignRepository;
|
| 42 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
58 |
import com.spice.profitmandi.dao.repository.fofo.CurrentInventorySnapshotRepository;
|
| 43 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
59 |
import com.spice.profitmandi.dao.repository.fofo.FofoOrderItemRepository;
|
| - |
|
60 |
import com.spice.profitmandi.dao.repository.fofo.HygieneDataRepository;
|
| 44 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
61 |
import com.spice.profitmandi.dao.repository.fofo.PartnerDailyInvestmentRepository;
|
| 45 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
62 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTargetRepository;
|
| 46 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
63 |
import com.spice.profitmandi.dao.repository.fofo.PartnerTypeChangeService;
|
| 47 |
import com.spice.profitmandi.dao.repository.fofo.TargetSlabRepository;
|
64 |
import com.spice.profitmandi.dao.repository.fofo.TargetSlabRepository;
|
| - |
|
65 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 48 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
66 |
import com.spice.profitmandi.service.PartnerInvestmentService;
|
| 49 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
67 |
import com.spice.profitmandi.service.authentication.RoleManager;
|
| 50 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
68 |
import com.spice.profitmandi.service.inventory.InventoryService;
|
| 51 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
69 |
import com.spice.profitmandi.service.slab.TargetSlabService;
|
| 52 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
70 |
import com.spice.profitmandi.service.transaction.TransactionService;
|
| Line 127... |
Line 145... |
| 127 |
private InsuranceProviderRepository insuranceProviderRepository;
|
145 |
private InsuranceProviderRepository insuranceProviderRepository;
|
| 128 |
@Autowired
|
146 |
@Autowired
|
| 129 |
private PartnerTypeChangeService partnerTypeChangeService;
|
147 |
private PartnerTypeChangeService partnerTypeChangeService;
|
| 130 |
|
148 |
|
| 131 |
@Autowired
|
149 |
@Autowired
|
| - |
|
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
|
| 132 |
private Mongo mongoClient;
|
162 |
private Mongo mongoClient;
|
| 133 |
|
163 |
|
| - |
|
164 |
@Autowired
|
| - |
|
165 |
private Gson gson;
|
| - |
|
166 |
|
| 134 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
167 |
private static final Logger LOGGER = LogManager.getLogger(DashboardController.class);
|
| 135 |
|
168 |
|
| 136 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
169 |
@RequestMapping(value = "/12dashboard34", method = RequestMethod.GET)
|
| 137 |
public String dashboard1(HttpServletRequest request, Model model) throws Exception {
|
170 |
public String dashboard1(HttpServletRequest request, Model model) throws Exception {
|
| 138 |
LOGGER.info("In Dashboard1");
|
171 |
LOGGER.info("In Dashboard1");
|
| 139 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
172 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 140 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
173 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 141 |
model.addAttribute("isAdmin", isAdmin);
|
174 |
model.addAttribute("isAdmin", isAdmin);
|
| 142 |
if (!isAdmin) {
|
175 |
if (!isAdmin) {
|
| - |
|
176 |
// model.addAttribute("brandStockPrices",
|
| 143 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
177 |
// this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 144 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
178 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 145 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
179 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 146 |
return "dashboard1";
|
180 |
return "dashboard1";
|
| 147 |
}
|
181 |
}
|
| 148 |
return "dashboard1";
|
182 |
return "dashboard1";
|
| 149 |
}
|
183 |
}
|
| 150 |
|
184 |
|
| 151 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
185 |
private Map<String, Object> getInvestments(int fofoId) throws Exception {
|
| 152 |
Map<String, Object> investments = new LinkedHashMap<>();
|
186 |
Map<String, Object> investments = new LinkedHashMap<>();
|
| 153 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
187 |
PartnerDailyInvestment investment = partnerInvestmentService.getInvestment(fofoId, 1);
|
| - |
|
188 |
LocalDate currentMonthStart = LocalDate.now().withDayOfMonth(1);
|
| 154 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
189 |
LocalDate yesterDate = LocalDate.now().minusDays(1);
|
| 155 |
LocalDate currentMonthStart = yesterDate.withDayOfMonth(1);
|
- |
|
| 156 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
190 |
PartnerDailyInvestment yesterdayInvestment = partnerDailyInvestmentRepository.select(fofoId, yesterDate);
|
| 157 |
if (yesterdayInvestment == null) {
|
191 |
if (yesterdayInvestment == null) {
|
| 158 |
yesterdayInvestment = new PartnerDailyInvestment();
|
192 |
yesterdayInvestment = new PartnerDailyInvestment();
|
| 159 |
}
|
193 |
}
|
| 160 |
|
194 |
|
| Line 166... |
Line 200... |
| 166 |
investments.put("today", investment.getTotalInvestment());
|
200 |
investments.put("today", investment.getTotalInvestment());
|
| 167 |
investments.put("investment", investment);
|
201 |
investments.put("investment", investment);
|
| 168 |
investments.put("inStock", investment.getInStockAmount());
|
202 |
investments.put("inStock", investment.getInStockAmount());
|
| 169 |
investments.put("minimum", investment.getMinInvestmentString());
|
203 |
investments.put("minimum", investment.getMinInvestmentString());
|
| 170 |
investments.put("short", investment.getShortPercentage());
|
204 |
investments.put("short", investment.getShortPercentage());
|
| 171 |
investments.put("okDays", okInvestmentDays + (yesterDate.getDayOfMonth() - currentMonthInvestments.size()));
|
205 |
investments.put("okDays", okInvestmentDays);
|
| 172 |
return investments;
|
206 |
return investments;
|
| 173 |
}
|
207 |
}
|
| 174 |
|
208 |
|
| 175 |
private Map<String, Object> getSales(int fofoId) {
|
209 |
private Map<String, Object> getSales(int fofoId) {
|
| 176 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
210 |
Map<String, Object> salesMap = new LinkedHashMap<>();
|
| Line 214... |
Line 248... |
| 214 |
salesMap.put("todaySale", todaySale);
|
248 |
salesMap.put("todaySale", todaySale);
|
| 215 |
salesMap.put("mtdSale", mtdSale);
|
249 |
salesMap.put("mtdSale", mtdSale);
|
| 216 |
return salesMap;
|
250 |
return salesMap;
|
| 217 |
}
|
251 |
}
|
| 218 |
|
252 |
|
| - |
|
253 |
/*
|
| 219 |
private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws Exception {
|
254 |
* private List<BrandStockPrice> getBrandStockPrices(int fofoId) throws
|
| - |
|
255 |
* Exception { Map<String, BrandStockPrice> brandStockPricesMap =
|
| 220 |
Map<String, BrandStockPrice> brandStockPricesMap = inventoryService.getBrandWiseStockValue(fofoId);
|
256 |
* inventoryService.getBrandWiseStockValue(fofoId);
|
| 221 |
|
257 |
*
|
| 222 |
List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
258 |
* List<DBObject> mobileBrands = mongoClient.getMongoBrands(fofoId, "", 3);
|
| 223 |
List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
259 |
* List<BrandStockPrice> brandStockPrices = new ArrayList<>();
|
| 224 |
|
260 |
*
|
| 225 |
mobileBrands.stream().forEach(x -> {
|
- |
|
| 226 |
String brand = (String) x.get("name");
|
261 |
* mobileBrands.stream().forEach(x -> { String brand = (String) x.get("name");
|
| 227 |
if (brandStockPricesMap.containsKey(brand)) {
|
262 |
* if (brandStockPricesMap.containsKey(brand)) { BrandStockPrice brandStockPrice
|
| 228 |
BrandStockPrice brandStockPrice = brandStockPricesMap.get(brand);
|
263 |
* = brandStockPricesMap.get(brand); brandStockPrice.setBrandUrl((String)
|
| 229 |
brandStockPrice.setBrandUrl((String) x.get("url"));
|
- |
|
| 230 |
brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
264 |
* x.get("url")); brandStockPrice.setRank(((Double) x.get("rank")).intValue());
|
| 231 |
brandStockPrices.add(brandStockPrice);
|
265 |
* brandStockPrices.add(brandStockPrice); } });
|
| 232 |
}
|
266 |
*
|
| 233 |
});
|
- |
|
| 234 |
|
- |
|
| 235 |
return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x, y) -> x.getRank() - y.getRank())
|
267 |
* return brandStockPrices.stream().filter(x -> x.getTotalQty() > 0).sorted((x,
|
| 236 |
.collect(Collectors.toList());
|
268 |
* y) -> x.getRank() - y.getRank()) .collect(Collectors.toList()); }
|
| 237 |
}
|
269 |
*/
|
| 238 |
|
270 |
|
| 239 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
271 |
@RequestMapping(value = "/dashboard", method = RequestMethod.GET)
|
| 240 |
public String dashboard(HttpServletRequest request, Model model) throws Exception {
|
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 {
|
| 241 |
|
274 |
|
| 242 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
275 |
LoginDetails loginDetails = cookiesProcessor.getCookiesObject(request);
|
| 243 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
276 |
boolean isAdmin = roleManager.isAdmin(loginDetails.getRoleIds());
|
| 244 |
model.addAttribute("isAdmin", isAdmin);
|
277 |
model.addAttribute("isAdmin", isAdmin);
|
| 245 |
|
278 |
|
| Line 255... |
Line 288... |
| 255 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
288 |
fofoStore = fofoStoreRepository.selectByRetailerId(loginDetails.getFofoId());
|
| 256 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
289 |
PartnerType partnerType = partnerTypeChangeService.getTypeOnDate(fofoStore.getId(), LocalDate.now());
|
| 257 |
if (!fofoStore.isActive()) {
|
290 |
if (!fofoStore.isActive()) {
|
| 258 |
return "redirect:/login";
|
291 |
return "redirect:/login";
|
| 259 |
}
|
292 |
}
|
| - |
|
293 |
|
| 260 |
LOGGER.info("partnerType {}", partnerType);
|
294 |
LOGGER.info("partnerType {}", partnerType);
|
| 261 |
|
295 |
|
| 262 |
model.addAttribute("partnerType", partnerType);
|
296 |
model.addAttribute("partnerType", partnerType);
|
| 263 |
model.addAttribute("fofoStore", fofoStore);
|
297 |
model.addAttribute("fofoStore", fofoStore);
|
| 264 |
model.addAttribute("partnerType", partnerType);
|
298 |
model.addAttribute("partnerType", partnerType);
|
| 265 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
299 |
model.addAttribute("hasGift", hasGift(loginDetails.getFofoId()));
|
| 266 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
300 |
model.addAttribute("giftItemId", ProfitMandiConstants.GIFT_ID);
|
| 267 |
|
301 |
|
| - |
|
302 |
// model.addAttribute("brandStockPrices",
|
| 268 |
model.addAttribute("brandStockPrices", this.getBrandStockPrices(loginDetails.getFofoId()));
|
303 |
// this.getBrandStockPrices(loginDetails.getFofoId()));
|
| 269 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
304 |
model.addAttribute("salesMap", this.getSales(loginDetails.getFofoId()));
|
| 270 |
// this.setInvestments
|
305 |
// this.setInvestments
|
| 271 |
//
|
306 |
//
|
| 272 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
307 |
model.addAttribute("investments", this.getInvestments(loginDetails.getFofoId()));
|
| 273 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
308 |
model.addAttribute("isInvestmentOk", partnerInvestmentService.isInvestmentOk(loginDetails.getFofoId(),
|
| Line 275... |
Line 310... |
| 275 |
} catch (ProfitMandiBusinessException e) {
|
310 |
} catch (ProfitMandiBusinessException e) {
|
| 276 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
311 |
LOGGER.error("FofoStore Code not found of fofoId {}", loginDetails.getFofoId());
|
| 277 |
|
312 |
|
| 278 |
}
|
313 |
}
|
| 279 |
}
|
314 |
}
|
| - |
|
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 |
|
| 280 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
331 |
model.addAttribute("monthDays", LocalDate.now().minusDays(1).lengthOfMonth());
|
| 281 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
332 |
model.addAttribute("dayOfMonth", LocalDate.now().minusDays(1).getDayOfMonth());
|
| 282 |
return "dashboard1";
|
333 |
return "dashboard1";
|
| 283 |
}
|
334 |
}
|
| 284 |
|
335 |
|
| Line 296... |
Line 347... |
| 296 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
347 |
public String contactUs(HttpServletRequest request, Model model) throws Throwable {
|
| 297 |
model.addAttribute("appContextPath", request.getContextPath());
|
348 |
model.addAttribute("appContextPath", request.getContextPath());
|
| 298 |
return "contact-us";
|
349 |
return "contact-us";
|
| 299 |
}
|
350 |
}
|
| 300 |
|
351 |
|
| - |
|
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 |
|
| 301 |
}
|
452 |
}
|