Subversion Repositories SmartDukaan

Rev

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

Rev 32874 Rev 33025
Line 89... Line 89...
89
        nc.setMessageType(sendNotificationModel.getMessageType());
89
        nc.setMessageType(sendNotificationModel.getMessageType());
90
        nc.setDocumentId(sendNotificationModel.getDocumentId());
90
        nc.setDocumentId(sendNotificationModel.getDocumentId());
91
        nc.setCreatedTimestamp(LocalDateTime.now());
91
        nc.setCreatedTimestamp(LocalDateTime.now());
92
        notificationCampaignRepository.persist(nc);
92
        notificationCampaignRepository.persist(nc);
93
 
93
 
94
        UserCampaign uc = null;
-
 
95
 
-
 
96
        Set<Integer> userIds = new HashSet<>();
94
        Set<Integer> userIds = new HashSet<>();
97
        if (sendNotificationModel.getUserIds() != null && sendNotificationModel.getUserIds().size() > 0) {
95
        if (sendNotificationModel.getUserIds() != null && sendNotificationModel.getUserIds().size() > 0) {
98
            userIds.addAll(sendNotificationModel.getUserIds());
96
            userIds.addAll(sendNotificationModel.getUserIds());
99
        }
97
        }
100
 
98
 
101
        if (sendNotificationModel.getStateIds() != null && sendNotificationModel.getStateIds().size() > 0) {
99
        if (sendNotificationModel.getStateIds() != null && sendNotificationModel.getStateIds().size() > 0) {
102
            userIds.addAll(fofoStoreRepository.selectByWarehouseIds(sendNotificationModel.getStateIds()).stream()
100
            List<Integer> fofoIds = fofoStoreRepository.selectByWarehouseIds(sendNotificationModel.getStateIds()).stream()
103
                    .map(x -> x.getId()).collect(Collectors.toList()));
101
                    .map(x -> x.getId()).collect(Collectors.toList());
-
 
102
            if(fofoIds.size() > 0) {
-
 
103
                userIds.addAll(userAccountRepository.selectUserIdsByRetailerIds(fofoIds));
104
        }
104
            }
105
 
-
 
106
        LOGGER.info("userIds" + userIds);
-
 
107
 
105
 
108
        for (Integer userId : userIds) {
-
 
109
            uc = new UserCampaign();
-
 
110
            uc.setCampaignId(nc.getId());
-
 
111
            uc.setUserId(userId);
-
 
112
            uc.setPushTimestamp(LocalDateTime.now());
-
 
113
            userCampaignRepository.persist(uc);
-
 
114
        }
106
        }
115
 
107
 
-
 
108
        if(userIds.size() > 0) {
-
 
109
            for (Integer userId : userIds) {
-
 
110
                UserCampaign uc = new UserCampaign();
-
 
111
                uc.setCampaignId(nc.getId());
-
 
112
                uc.setUserId(userId);
-
 
113
                uc.setPushTimestamp(LocalDateTime.now());
-
 
114
                userCampaignRepository.persist(uc);
-
 
115
            }
116
        List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(new ArrayList<>(userIds),
116
            List<Device> devices = deviceRepository.selectByUserIdAndModifiedTimestamp(new ArrayList<>(userIds),
117
                LocalDateTime.now().minusMonths(3), LocalDateTime.now());
117
                    LocalDateTime.now().minusMonths(1), LocalDateTime.now());
118
 
-
 
119
        LOGGER.info("devices" + devices);
118
            pushNotification(nc.getId(), devices);
-
 
119
        } else {
120
        pushNotification(nc.getId(), devices);
120
            LOGGER.info("Failed to send notification to any retailer with this model - {}", sendNotificationModel);
-
 
121
        }
121
 
122
 
122
    }
123
    }
123
 
124
 
124
    @Override
125
    @Override
125
    public void sendNotificationToAll(SendNotificationModel sendNotificationModel) throws ProfitMandiBusinessException {
126
    public void sendNotificationToAll(SendNotificationModel sendNotificationModel) throws ProfitMandiBusinessException {
Line 195... Line 196...
195
    }
196
    }
196
 
197
 
197
    @Override
198
    @Override
198
    public void sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName, WhatsappMessageType whatsappMessageType)
199
    public void sendWhatsappMediaMessage(String message, String mobile, String mediaUrl, String fileName, WhatsappMessageType whatsappMessageType)
199
            throws Exception {
200
            throws Exception {
200
        if(isProd) {
201
        if (isProd) {
201
            this.sendWhatsappMessage(whatsappMessageType, message, null, mobile, mediaUrl, fileName);
202
            this.sendWhatsappMessage(whatsappMessageType, message, null, mobile, mediaUrl, fileName);
202
        }
203
        }
203
 
204
 
204
    }
205
    }
205
 
206