| Line 231... |
Line 231... |
| 231 |
sendNotificationModel.setImageUrl(IMAGE_STATIC_SERVER_URL + "/" + "image" + LocalDate.now() + "/" + fileName);
|
231 |
sendNotificationModel.setImageUrl(IMAGE_STATIC_SERVER_URL + "/" + "image" + LocalDate.now() + "/" + fileName);
|
| 232 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
232 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 233 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
233 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 234 |
sendNotificationModel.setMessageType(MessageType.scheme);
|
234 |
sendNotificationModel.setMessageType(MessageType.scheme);
|
| 235 |
Map<Integer, List<Offer>> offersMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
|
235 |
Map<Integer, List<Offer>> offersMap = offerRepository.selectAllPublishedMapByPartner(YearMonth.now());
|
| 236 |
List<Integer> fofoIds = offersMap.entrySet().stream().filter(x -> x.getValue().contains(offer))
|
- |
|
| 237 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
- |
|
| 238 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
- |
|
| 239 |
sendNotificationModel.setUserIds(userIds);
|
- |
|
| - |
|
236 |
|
| 240 |
Map<String, InputStream> fileStreamsMap = new HashMap<>();
|
237 |
Map<String, InputStream> fileStreamsMap = new HashMap<>();
|
| 241 |
Map<String, Object> model = new HashMap<>();
|
238 |
Map<String, Object> model = new HashMap<>();
|
| 242 |
model.put("offer", createOfferRequest);
|
239 |
model.put("offer", createOfferRequest);
|
| 243 |
String htmlContent = this.getContentFromTemplate("offer_margin_detail_partner.vm", model);
|
240 |
String htmlContent = this.getContentFromTemplate("offer_margin_detail_partner.vm", model);
|
| 244 |
LOGGER.info("this.getContentFromTemplate {}", htmlContent);
|
241 |
LOGGER.info("this.getContentFromTemplate {}", htmlContent);
|
| 245 |
fileStreamsMap.put(fileName, this.getImageBuffer(htmlContent));
|
242 |
fileStreamsMap.put(fileName, this.getImageBuffer(htmlContent));
|
| 246 |
//fileStreamsMap.put(htmlFileName, new ByteArrayInputStream(htmlContent.getBytes()));
|
243 |
//fileStreamsMap.put(htmlFileName, new ByteArrayInputStream(htmlContent.getBytes()));
|
| 247 |
|
244 |
|
| 248 |
this.uploadFile(fileStreamsMap);
|
245 |
this.uploadFile(fileStreamsMap);
|
| - |
|
246 |
if (createOfferRequest.getPartnerCriteria().getRegionIds().size() > 0
|
| - |
|
247 |
|| createOfferRequest.getPartnerCriteria().getFofoIds().size() > 0
|
| - |
|
248 |
|| createOfferRequest.getPartnerCriteria().getRegionIds().size() > 0) {
|
| - |
|
249 |
List<Integer> fofoIds = offersMap.entrySet().stream().filter(x -> x.getValue().contains(offer))
|
| - |
|
250 |
.map(x -> x.getKey()).collect(Collectors.toList());
|
| - |
|
251 |
List<Integer> userIds = userAccountRepository.selectUserIdsByRetailerIds(fofoIds);
|
| - |
|
252 |
sendNotificationModel.setUserIds(userIds);
|
| - |
|
253 |
/*if(createOfferRequest.getPartnerCriteria().getRegionIds().size() > 0) {
|
| - |
|
254 |
List<Integer> regionIds = createOfferRequest.getPartnerCriteria().getRegionIds();
|
| - |
|
255 |
}*/
|
| 249 |
notificationService.sendNotification(sendNotificationModel);
|
256 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
257 |
} else {
|
| - |
|
258 |
notificationService.sendNotificationToAll(sendNotificationModel);
|
| - |
|
259 |
}
|
| 250 |
|
260 |
|
| 251 |
}
|
261 |
}
|
| 252 |
|
262 |
|
| 253 |
private InputStream asInputStream(BufferedImage bi) throws Exception {
|
263 |
private InputStream asInputStream(BufferedImage bi) throws Exception {
|
| 254 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
264 |
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|