| Line 314... |
Line 314... |
| 314 |
}
|
314 |
}
|
| 315 |
|
315 |
|
| 316 |
if (!dispatchNotication.isEmpty()) {
|
316 |
if (!dispatchNotication.isEmpty()) {
|
| 317 |
|
317 |
|
| 318 |
for (Entry<String, DispatchNotificationModel> dn : dispatchNotication.entrySet()) {
|
318 |
for (Entry<String, DispatchNotificationModel> dn : dispatchNotication.entrySet()) {
|
| 319 |
|
- |
|
| - |
|
319 |
DispatchNotificationModel dispatchNotificationModel = dn.getValue();
|
| - |
|
320 |
//Send message only if shipping date is within T+1 of upload date
|
| - |
|
321 |
if(dispatchNotificationModel.getShippingDate().isAfter(LocalDate.now().minusDays(2))) {
|
| 320 |
Provider pr = providerRepository.selectById(dn.getValue().getProviderId());
|
322 |
Provider pr = providerRepository.selectById(dispatchNotificationModel.getProviderId());
|
| 321 |
|
323 |
|
| 322 |
String title = "Order Shipped";
|
324 |
String title = "Order Shipped";
|
| 323 |
|
325 |
|
| 324 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(dn.getValue().getFofoId());
|
326 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(dn.getValue().getFofoId());
|
| 325 |
|
327 |
|
| 326 |
Address address = addressRepository.selectById(user.getAddressId());
|
- |
|
| 327 |
|
328 |
|
| 328 |
Set<String> invoiceNumber = new HashSet<>();
|
329 |
Set<String> invoiceNumber = new HashSet<>();
|
| 329 |
invoiceNumber.addAll(dn.getValue().getInvoiceNumber());
|
330 |
invoiceNumber.addAll(dn.getValue().getInvoiceNumber());
|
| 330 |
|
331 |
|
| 331 |
String message = String.format("Dear partner, your items with Invoice Number " + String.join(",", invoiceNumber) + " worth Rs." + dn.getValue().getTotalAmount() + " and qty " + dn.getValue().getTotalQty() + " has been shipped through " + pr.getName() + " via your track id " + dn.getKey() + " and will be delivered by " + dn.getValue().getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ".");
|
332 |
String message = String.format("Dear partner, your items with Invoice Number " + String.join(",", invoiceNumber) + " worth Rs." + dn.getValue().getTotalAmount() + " and qty " + dn.getValue().getTotalQty() + " has been shipped through " + pr.getName() + " via your track id " + dn.getKey() + " and expected to be delivered by " + dn.getValue().getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ".");
|
| 332 |
|
333 |
|
| 333 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
334 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 334 |
sendNotificationModel.setCampaignName("Order Shipped");
|
335 |
sendNotificationModel.setCampaignName("Order Shipped");
|
| 335 |
sendNotificationModel.setTitle(title);
|
336 |
sendNotificationModel.setTitle(title);
|
| 336 |
sendNotificationModel.setMessage(message);
|
337 |
sendNotificationModel.setMessage(message);
|
| 337 |
sendNotificationModel.setType("url");
|
338 |
sendNotificationModel.setType("url");
|
| 338 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
339 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 339 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
340 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 340 |
sendNotificationModel.setMessageType(MessageType.notification);
|
341 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 341 |
int userId = userAccountRepository.selectUserIdByRetailerId(dn.getValue().getFofoId());
|
342 |
int userId = userAccountRepository.selectUserIdByRetailerId(dn.getValue().getFofoId());
|
| 342 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
343 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 343 |
notificationService.sendNotification(sendNotificationModel);
|
344 |
notificationService.sendNotification(sendNotificationModel);
|
| 344 |
//TODO-Whatsapp
|
345 |
}
|
| 345 |
//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
- |
|
| 346 |
}
|
346 |
}
|
| 347 |
|
347 |
|
| 348 |
}
|
348 |
}
|
| 349 |
}
|
349 |
}
|
| 350 |
|
350 |
|
| Line 747... |
Line 747... |
| 747 |
order.setStatus(OrderStatus.DELIVERY_SUCCESS);
|
747 |
order.setStatus(OrderStatus.DELIVERY_SUCCESS);
|
| 748 |
order.setStatusDescription("Order Delivered");
|
748 |
order.setStatusDescription("Order Delivered");
|
| 749 |
|
749 |
|
| 750 |
}
|
750 |
}
|
| 751 |
|
751 |
|
| 752 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository.selectById(orders.get(0).getRetailerId());
|
752 |
//Send notification only if the case is of T + 2 days
|
| 753 |
|
- |
|
| 754 |
Address address = addressRepository.selectById(user.getAddressId());
|
753 |
if(orders.get(0).getDeliveryTimestamp().toLocalDate().isBefore(LocalDate.now().plusDays(2))) {
|
| 755 |
|
- |
|
| 756 |
String title = "Order Delivered";
|
754 |
String title = "Order Delivered";
|
| 757 |
|
755 |
|
| 758 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
756 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 759 |
sendNotificationModel.setCampaignName("Order Delivered");
|
757 |
sendNotificationModel.setCampaignName("Order Delivered");
|
| 760 |
sendNotificationModel.setTitle(title);
|
758 |
sendNotificationModel.setTitle(title);
|
| 761 |
sendNotificationModel.setMessage(String.format("Dear partner, your SmartDukaan Order " + dl.getAirwayBillNumber() + " has been delivered on" + dl.getDeliveredOn().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " to you in a safe, sealed bag by " + dl.getDeliveredBy() + "."));
|
759 |
sendNotificationModel.setMessage(String.format("Dear partner, your SmartDukaan Order " + dl.getAirwayBillNumber() + " has been delivered on" + dl.getDeliveredOn().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + " to you in a safe, sealed bag by " + dl.getDeliveredBy() + "."));
|
| 762 |
sendNotificationModel.setType("url");
|
760 |
sendNotificationModel.setType("url");
|
| 763 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
761 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 764 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
762 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 765 |
sendNotificationModel.setMessageType(MessageType.notification);
|
763 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 766 |
int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
|
764 |
int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
|
| 767 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
765 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 768 |
notificationService.sendNotification(sendNotificationModel);
|
766 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
767 |
}
|
| 769 |
|
768 |
|
| 770 |
//String message = String.format("Dear partner, Your SmartDukaan Order " + dl.getAirwayBillNumber() + " has been delivered to you in a safe sealed bag.");
|
769 |
//String message = String.format("Dear partner, Your SmartDukaan Order " + dl.getAirwayBillNumber() + " has been delivered to you in a safe sealed bag.");
|
| 771 |
|
- |
|
| 772 |
//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
770 |
//notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 773 |
|
771 |
|
| 774 |
} else {
|
772 |
} else {
|
| 775 |
throw new ProfitMandiBusinessException("Upload File", "", "No order available for " + dl.getAirwayBillNumber() + " airwaybill Number");
|
773 |
throw new ProfitMandiBusinessException("Upload File", "", "No order available for " + dl.getAirwayBillNumber() + " airwaybill Number");
|
| 776 |
|
774 |
|