Subversion Repositories SmartDukaan

Rev

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

Rev 34568 Rev 34586
Line 367... Line 367...
367
        if (schemes == null || schemes.isEmpty()) return;
367
        if (schemes == null || schemes.isEmpty()) return;
368
 
368
 
369
        SendNotificationModel sendNotificationModel = new SendNotificationModel();
369
        SendNotificationModel sendNotificationModel = new SendNotificationModel();
370
        StringBuilder messageBuilder = new StringBuilder();
370
        StringBuilder messageBuilder = new StringBuilder();
371
        StringBuilder titleBuilder = new StringBuilder();
371
        StringBuilder titleBuilder = new StringBuilder();
372
        Set<Integer> allCatalogIds = new HashSet<>();
-
 
373
 
372
 
374
        for (Scheme scheme : schemes) {
373
        for (Scheme scheme : schemes) {
375
            if (!ACTIVATION_SCHEME_TYPES.contains(scheme.getType())) {
374
            if (!ACTIVATION_SCHEME_TYPES.contains(scheme.getType())) {
376
                continue;
375
                continue;
377
            }
376
            }
Line 381... Line 380...
381
                schemeTypeLabel = "Special Support";
380
                schemeTypeLabel = "Special Support";
382
            }
381
            }
383
 
382
 
384
            List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(Collections.singleton(scheme.getId()));
383
            List<SchemeItem> schemeItems = schemeItemRepository.selectBySchemeIds(Collections.singleton(scheme.getId()));
385
            Set<Integer> catalogIds = schemeItems.stream().map(SchemeItem::getCatalogId).collect(Collectors.toSet());
384
            Set<Integer> catalogIds = schemeItems.stream().map(SchemeItem::getCatalogId).collect(Collectors.toSet());
386
            allCatalogIds.addAll(catalogIds);
-
 
387
 
385
 
388
            List<String> itemBrand = itemRepository.selectAllByCatalogIds(catalogIds).stream()
386
            List<String> itemBrand = itemRepository.selectAllByCatalogIds(catalogIds).stream()
389
                    .filter(Utils.distinctByKey(Item::getCatalogItemId))
387
                    .filter(Utils.distinctByKey(Item::getCatalogItemId))
390
                    .map(Item::getBrand)
388
                    .map(Item::getBrand)
391
                    .collect(Collectors.toList());
389
                    .collect(Collectors.toList());
Line 397... Line 395...
397
 
395
 
398
            // Title line
396
            // Title line
399
            titleBuilder.append(String.format("%s of Rs.%s for %s\n",
397
            titleBuilder.append(String.format("%s of Rs.%s for %s\n",
400
                    schemeTypeLabel,
398
                    schemeTypeLabel,
401
                    FormattingUtils.formatDecimal(scheme.getAmount()),
399
                    FormattingUtils.formatDecimal(scheme.getAmount()),
402
                    itemBrand.get(0)));
400
                    String.join(", ", itemDescriptions)));
403
 
401
 
404
            // Message details
402
            // Message details
405
            messageBuilder.append(String.format("On Selected Models: %s\n", String.join(", ", itemDescriptions)));
-
 
406
            messageBuilder.append(String.format("Duration from - %s to %s\n\n",
403
            messageBuilder.append(String.format("Duration from - %s to %s\n\n",
407
                FormattingUtils.formatDateMonth(scheme.getStartDateTime()),
404
                FormattingUtils.formatDateMonth(scheme.getStartDateTime()),
408
                FormattingUtils.formatDateMonth(scheme.getEndDateTime())));
405
                FormattingUtils.formatDateMonth(scheme.getEndDateTime())));
409
        }
406
        }
410
 
407
 
-
 
408
        LOGGER.info("titleBuilder: {} {}",titleBuilder.toString(),messageBuilder.toString());
-
 
409
 
411
        if (titleBuilder.length() == 0) return;
410
        if (titleBuilder.length() == 0) return;
412
 
411
 
413
        sendNotificationModel.setCampaignName("activationscheme");
412
        sendNotificationModel.setCampaignName("activationscheme");
414
        sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
413
        sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
415
        sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
414
        sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
416
        sendNotificationModel.setTitle(titleBuilder.toString().trim());
415
        sendNotificationModel.setTitle("Special Offer");
417
        sendNotificationModel.setMessage(messageBuilder.toString().trim());
416
        sendNotificationModel.setMessage(messageBuilder.toString());
418
        sendNotificationModel.setType("url");
417
        sendNotificationModel.setType("url");
419
        sendNotificationModel.setMessageType(MessageType.scheme);
418
        sendNotificationModel.setMessageType(MessageType.scheme);
420
        notificationService.sendNotificationToAll(sendNotificationModel);
419
        notificationService.sendNotificationToAll(sendNotificationModel);
421
    }
420
    }
422
 
421