| Line 285... |
Line 285... |
| 285 |
* SchemeType.OUT) { this.processPreviousSales(scheme); }
|
285 |
* SchemeType.OUT) { this.processPreviousSales(scheme); }
|
| 286 |
*/
|
286 |
*/
|
| 287 |
}
|
287 |
}
|
| 288 |
|
288 |
|
| 289 |
private void sendSchemeNotification(Scheme scheme) throws ProfitMandiBusinessException {
|
289 |
private void sendSchemeNotification(Scheme scheme) throws ProfitMandiBusinessException {
|
| 290 |
if (scheme.getType().equals(SchemeType.ACTIVATION)) {
|
290 |
if (Arrays.asList(SchemeType.SPECIAL_SUPPORT, SchemeType.ACTIVATION).contains(scheme.getType())) {
|
| 291 |
|
291 |
|
| 292 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
292 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 293 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(Collections.singleton(scheme.getId()));
|
293 |
List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(Collections.singleton(scheme.getId()));
|
| 294 |
Set<Integer> catalogIds = schemeItems.stream().map(x -> x.getCatalogId()).collect(Collectors.toSet());
|
294 |
Set<Integer> catalogIds = schemeItems.stream().map(x -> x.getCatalogId()).collect(Collectors.toSet());
|
| 295 |
List<String> itemDescriptions = itemRepository.selectAllByCatalogIds(catalogIds).stream().filter(Utils.distinctByKey(Item::getCatalogItemId))
|
295 |
List<String> itemDescriptions = itemRepository.selectAllByCatalogIds(catalogIds).stream().filter(Utils.distinctByKey(Item::getCatalogItemId))
|
| 296 |
.map(x -> x.getItemDescriptionNoColor()).collect(Collectors.toList());
|
296 |
.map(x -> x.getItemDescriptionNoColor()).collect(Collectors.toList());
|
| - |
|
297 |
String titleTemplate = "%s of Rs.%s for %s";
|
| - |
|
298 |
String schemeString = "Activation scheme";
|
| - |
|
299 |
if (scheme.getType().equals(SchemeType.SPECIAL_SUPPORT)) {
|
| - |
|
300 |
schemeString = "Special Support";
|
| - |
|
301 |
}
|
| 297 |
|
302 |
|
| 298 |
|
- |
|
| 299 |
String title = "Activation scheme of Rs." + FormattingUtils.formatDecimal(scheme.getAmount()) + " for " + String.join(", ", itemDescriptions);
|
- |
|
| 300 |
String message = "Duration from - " + FormattingUtils.formatDateMonth(scheme.getStartDateTime()) + " - " + FormattingUtils.formatDateMonth(scheme.getEndDateTime());
|
303 |
String message = "Duration from - " + FormattingUtils.formatDateMonth(scheme.getStartDateTime()) + " - " + FormattingUtils.formatDateMonth(scheme.getEndDateTime());
|
| 301 |
sendNotificationModel.setCampaignName("activationscheme");
|
304 |
sendNotificationModel.setCampaignName("activationscheme");
|
| 302 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/scheme/" + scheme.getId());
|
305 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/scheme/" + scheme.getId());
|
| 303 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
306 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 304 |
sendNotificationModel.setMessage(message);
|
307 |
sendNotificationModel.setMessage(message);
|
| 305 |
sendNotificationModel.setTitle(title);
|
308 |
sendNotificationModel.setTitle(String.format(titleTemplate, schemeString, FormattingUtils.formatDecimal(scheme.getAmount()), String.join(", ", itemDescriptions)));
|
| 306 |
sendNotificationModel.setType("url");
|
309 |
sendNotificationModel.setType("url");
|
| 307 |
sendNotificationModel.setMessageType(MessageType.scheme);
|
310 |
sendNotificationModel.setMessageType(MessageType.scheme);
|
| 308 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
311 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
| 309 |
}
|
312 |
}
|
| 310 |
}
|
313 |
}
|