Subversion Repositories SmartDukaan

Rev

Rev 34586 | Rev 34698 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 34586 Rev 34592
Line 362... Line 362...
362
            notificationService.sendNotificationToAll(sendNotificationModel);
362
            notificationService.sendNotificationToAll(sendNotificationModel);
363
        }
363
        }
364
    }
364
    }
365
 
365
 
366
    private void sendCombinedSchemesNotification(List<Scheme> schemes) throws ProfitMandiBusinessException {
366
    private void sendCombinedSchemesNotification(List<Scheme> schemes) throws ProfitMandiBusinessException {
367
        if (schemes == null || schemes.isEmpty()) return;
-
 
368
 
-
 
369
        SendNotificationModel sendNotificationModel = new SendNotificationModel();
367
        SendNotificationModel sendNotificationModel = new SendNotificationModel();
370
        StringBuilder messageBuilder = new StringBuilder();
368
        StringBuilder messageBuilder = new StringBuilder();
371
        StringBuilder titleBuilder = new StringBuilder();
-
 
372
 
369
 
373
        for (Scheme scheme : schemes) {
370
        for (Scheme scheme : schemes) {
374
            if (!ACTIVATION_SCHEME_TYPES.contains(scheme.getType())) {
371
            if (!ACTIVATION_SCHEME_TYPES.contains(scheme.getType())) {
375
                continue;
372
                continue;
376
            }
373
            }
Line 391... Line 388...
391
            List<String> itemDescriptions = itemRepository.selectAllByCatalogIds(catalogIds).stream()
388
            List<String> itemDescriptions = itemRepository.selectAllByCatalogIds(catalogIds).stream()
392
                    .filter(Utils.distinctByKey(Item::getCatalogItemId))
389
                    .filter(Utils.distinctByKey(Item::getCatalogItemId))
393
                    .map(Item::getItemDescriptionNoColor)
390
                    .map(Item::getItemDescriptionNoColor)
394
                    .collect(Collectors.toList());
391
                    .collect(Collectors.toList());
395
 
392
 
396
            // Title line
-
 
397
            titleBuilder.append(String.format("%s of Rs.%s for %s\n",
393
            messageBuilder.append(String.format("*%s* on *%s* of Rs.*%s* for *%s*\n Duration from - *%s to %s*\n\n",
398
                    schemeTypeLabel,
394
                    schemeTypeLabel,
-
 
395
                    itemBrand.get(0),
399
                    FormattingUtils.formatDecimal(scheme.getAmount()),
396
                    FormattingUtils.formatDecimal(scheme.getAmount()),
400
                    String.join(", ", itemDescriptions)));
397
                    String.join(", ", itemDescriptions),
-
 
398
                    FormattingUtils.formatDateMonth(scheme.getStartDateTime()),
-
 
399
                    FormattingUtils.formatDateMonth(scheme.getEndDateTime())));
401
 
400
 
402
            // Message details
-
 
403
            messageBuilder.append(String.format("Duration from - %s to %s\n\n",
-
 
404
                FormattingUtils.formatDateMonth(scheme.getStartDateTime()),
-
 
405
                FormattingUtils.formatDateMonth(scheme.getEndDateTime())));
-
 
406
        }
401
        }
407
 
402
 
408
        LOGGER.info("titleBuilder: {} {}",titleBuilder.toString(),messageBuilder.toString());
-
 
409
 
-
 
410
        if (titleBuilder.length() == 0) return;
-
 
411
 
-
 
412
        sendNotificationModel.setCampaignName("activationscheme");
403
        sendNotificationModel.setCampaignName("activationscheme");
413
        sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
404
        sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
414
        sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
405
        sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
415
        sendNotificationModel.setTitle("Special Offer");
406
        sendNotificationModel.setTitle("Special Support");
416
        sendNotificationModel.setMessage(messageBuilder.toString());
407
        sendNotificationModel.setMessage(messageBuilder.toString());
417
        sendNotificationModel.setType("url");
408
        sendNotificationModel.setType("url");
418
        sendNotificationModel.setMessageType(MessageType.scheme);
409
        sendNotificationModel.setMessageType(MessageType.scheme);
419
        notificationService.sendNotificationToAll(sendNotificationModel);
410
        notificationService.sendNotificationToAll(sendNotificationModel);
420
    }
411
    }