| Line 12... |
Line 12... |
| 12 |
import com.spice.profitmandi.dao.entity.logistics.Provider;
|
12 |
import com.spice.profitmandi.dao.entity.logistics.Provider;
|
| 13 |
import com.spice.profitmandi.dao.entity.logistics.ProviderDetails;
|
13 |
import com.spice.profitmandi.dao.entity.logistics.ProviderDetails;
|
| 14 |
import com.spice.profitmandi.dao.entity.logistics.ProviderTat;
|
14 |
import com.spice.profitmandi.dao.entity.logistics.ProviderTat;
|
| 15 |
import com.spice.profitmandi.dao.entity.logistics.PublicHolidays;
|
15 |
import com.spice.profitmandi.dao.entity.logistics.PublicHolidays;
|
| 16 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
16 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| - |
|
17 |
import com.spice.profitmandi.dao.entity.user.Address;
|
| 17 |
import com.spice.profitmandi.dao.model.*;
|
18 |
import com.spice.profitmandi.dao.model.*;
|
| 18 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
19 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 19 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
20 |
import com.spice.profitmandi.dao.repository.cs.CsService;
|
| 20 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
21 |
import com.spice.profitmandi.dao.repository.cs.PositionRepository;
|
| 21 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
22 |
import com.spice.profitmandi.dao.repository.dtr.UserAccountRepository;
|
| 22 |
import com.spice.profitmandi.dao.repository.logistics.ProviderDetailsRepository;
|
23 |
import com.spice.profitmandi.dao.repository.logistics.ProviderDetailsRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.logistics.ProviderRepository;
|
24 |
import com.spice.profitmandi.dao.repository.logistics.ProviderRepository;
|
| 24 |
import com.spice.profitmandi.dao.repository.logistics.ProviderTatRepository;
|
25 |
import com.spice.profitmandi.dao.repository.logistics.ProviderTatRepository;
|
| 25 |
import com.spice.profitmandi.dao.repository.logistics.PublicHolidaysRepository;
|
26 |
import com.spice.profitmandi.dao.repository.logistics.PublicHolidaysRepository;
|
| 26 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
27 |
import com.spice.profitmandi.dao.repository.transaction.OrderRepository;
|
| - |
|
28 |
import com.spice.profitmandi.dao.repository.user.AddressRepository;
|
| - |
|
29 |
import com.spice.profitmandi.dao.repository.user.UserRepository;
|
| 27 |
import com.spice.profitmandi.service.LogisticsService;
|
30 |
import com.spice.profitmandi.service.LogisticsService;
|
| 28 |
import com.spice.profitmandi.service.NotificationService;
|
31 |
import com.spice.profitmandi.service.NotificationService;
|
| 29 |
import com.spice.profitmandi.web.model.LoginDetails;
|
32 |
import com.spice.profitmandi.web.model.LoginDetails;
|
| 30 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
33 |
import com.spice.profitmandi.web.util.CookiesProcessor;
|
| 31 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
34 |
import com.spice.profitmandi.web.util.MVCResponseSender;
|
| Line 103... |
Line 106... |
| 103 |
CsService csService;
|
106 |
CsService csService;
|
| 104 |
|
107 |
|
| 105 |
@Autowired
|
108 |
@Autowired
|
| 106 |
private Gson gson;
|
109 |
private Gson gson;
|
| 107 |
|
110 |
|
| - |
|
111 |
@Autowired
|
| - |
|
112 |
private AddressRepository addressRepository;
|
| - |
|
113 |
|
| - |
|
114 |
@Autowired
|
| - |
|
115 |
private UserRepository userUserRepository;
|
| - |
|
116 |
|
| 108 |
private static final Logger LOGGER = LogManager.getLogger(LogisticsController.class);
|
117 |
private static final Logger LOGGER = LogManager.getLogger(LogisticsController.class);
|
| 109 |
|
118 |
|
| 110 |
@RequestMapping(value = "/logistics", method = RequestMethod.GET)
|
119 |
@RequestMapping(value = "/logistics", method = RequestMethod.GET)
|
| 111 |
public String logistics(HttpServletRequest request, Model model) throws Exception {
|
120 |
public String logistics(HttpServletRequest request, Model model) throws Exception {
|
| 112 |
ProviderTat pt = providerTatRepository.selectByProviderId(1, 7678, "110018");
|
121 |
ProviderTat pt = providerTatRepository.selectByProviderId(1, 7678, "110018");
|
| Line 261... |
Line 270... |
| 261 |
|
270 |
|
| 262 |
for (Entry<String, DispatchNotificationModel> dn : dispatchNotication.entrySet()) {
|
271 |
for (Entry<String, DispatchNotificationModel> dn : dispatchNotication.entrySet()) {
|
| 263 |
|
272 |
|
| 264 |
Provider pr = providerRepository.selectById(dn.getValue().getProviderId());
|
273 |
Provider pr = providerRepository.selectById(dn.getValue().getProviderId());
|
| 265 |
|
274 |
|
| - |
|
275 |
String title = "Order Shipped";
|
| - |
|
276 |
|
| - |
|
277 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository
|
| - |
|
278 |
.selectById(dn.getValue().getFofoId());
|
| - |
|
279 |
|
| - |
|
280 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
281 |
|
| 266 |
Set<String> invoiceNumber = new HashSet<>();
|
282 |
Set<String> invoiceNumber = new HashSet<>();
|
| 267 |
invoiceNumber.addAll(dn.getValue().getInvoiceNumber());
|
283 |
invoiceNumber.addAll(dn.getValue().getInvoiceNumber());
|
| 268 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 269 |
sendNotificationModel.setCampaignName("Order Shipped");
|
- |
|
| 270 |
sendNotificationModel.setTitle("Order Shipped");
|
- |
|
| - |
|
284 |
|
| 271 |
sendNotificationModel.setMessage(String.format("Dear partner, your items with Invoice Number "
|
285 |
String message = String.format("Dear partner, your items with Invoice Number "
|
| 272 |
+ String.join(",", invoiceNumber) + " worth Rs." + dn.getValue().getTotalAmount()
|
286 |
+ String.join(",", invoiceNumber) + " worth Rs." + dn.getValue().getTotalAmount()
|
| 273 |
+ " and qty " + dn.getValue().getTotalQty() + " has been shipped through " + pr.getName()
|
287 |
+ " and qty " + dn.getValue().getTotalQty() + " has been shipped through " + pr.getName()
|
| 274 |
+ " via your track id " + dn.getKey() + " and will be delivered by "
|
288 |
+ " via your track id " + dn.getKey() + " and will be delivered by "
|
| 275 |
+ dn.getValue().getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))));
|
289 |
+ dn.getValue().getDate().format(DateTimeFormatter.ofPattern("dd-MM-yyyy")) + ".");
|
| - |
|
290 |
|
| - |
|
291 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
292 |
sendNotificationModel.setCampaignName("Order Shipped");
|
| - |
|
293 |
sendNotificationModel.setTitle(title);
|
| - |
|
294 |
sendNotificationModel.setMessage(message);
|
| 276 |
sendNotificationModel.setType("url");
|
295 |
sendNotificationModel.setType("url");
|
| 277 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
296 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 278 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
297 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 279 |
sendNotificationModel.setMessageType(MessageType.notification);
|
298 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 280 |
int userId = userAccountRepository.selectUserIdByRetailerId(dn.getValue().getFofoId());
|
299 |
int userId = userAccountRepository.selectUserIdByRetailerId(dn.getValue().getFofoId());
|
| 281 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
300 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 282 |
notificationService.sendNotification(sendNotificationModel);
|
301 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
302 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 283 |
}
|
303 |
}
|
| 284 |
|
304 |
|
| 285 |
}
|
305 |
}
|
| 286 |
}
|
306 |
}
|
| 287 |
|
307 |
|
| Line 600... |
Line 620... |
| 600 |
|
620 |
|
| 601 |
LocalDate deliveryDate = logisticsService.calculateDeliveryTimeline(
|
621 |
LocalDate deliveryDate = logisticsService.calculateDeliveryTimeline(
|
| 602 |
order.getShippingTimestamp().toLocalDate(), pt, ddm.getDelayDay());
|
622 |
order.getShippingTimestamp().toLocalDate(), pt, ddm.getDelayDay());
|
| 603 |
|
623 |
|
| 604 |
orders.forEach(x -> x.setExpectedDeliveryTime(deliveryDate.atStartOfDay()));
|
624 |
orders.forEach(x -> x.setExpectedDeliveryTime(deliveryDate.atStartOfDay()));
|
| 605 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
- |
|
| 606 |
sendNotificationModel.setCampaignName("Order Update");
|
- |
|
| - |
|
625 |
|
| 607 |
sendNotificationModel.setTitle("Order Update");
|
626 |
String title = "Order Update";
|
| 608 |
sendNotificationModel.setMessage(String
|
627 |
String message = String
|
| 609 |
.format("Dear partner, your items with Invoice Number " + String.join(",", invoiceNumbers)
|
628 |
.format("Dear partner, your items with Invoice Number " + String.join(",", invoiceNumbers)
|
| 610 |
+ " worth Rs." + totalAmount + " and qty " + totalQty + " has been shipped through "
|
629 |
+ " worth Rs." + totalAmount + " and qty " + totalQty + " has been shipped through "
|
| 611 |
+ providerRepository.selectById(order.getLogisticsProviderId()).getName()
|
630 |
+ providerRepository.selectById(order.getLogisticsProviderId()).getName()
|
| 612 |
+ " via your track id " + ddm.getAirwayBIllNumber() + " has been delayed due to "
|
631 |
+ " via your track id " + ddm.getAirwayBIllNumber() + " has been delayed due to "
|
| 613 |
+ ddm.getReason() + " and will be delivered by "
|
632 |
+ ddm.getReason() + " and will be delivered by "
|
| 614 |
+ deliveryDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy"))));
|
633 |
+ deliveryDate.format(DateTimeFormatter.ofPattern("dd-MM-yyyy")))
|
| - |
|
634 |
+ ".";
|
| - |
|
635 |
|
| - |
|
636 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository
|
| - |
|
637 |
.selectById(order.getRetailerId());
|
| - |
|
638 |
|
| - |
|
639 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
640 |
|
| - |
|
641 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| - |
|
642 |
sendNotificationModel.setCampaignName("Order Update");
|
| - |
|
643 |
sendNotificationModel.setTitle(title);
|
| - |
|
644 |
sendNotificationModel.setMessage(message);
|
| 615 |
sendNotificationModel.setType("url");
|
645 |
sendNotificationModel.setType("url");
|
| 616 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
646 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 617 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
647 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 618 |
sendNotificationModel.setMessageType(MessageType.notification);
|
648 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 619 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
649 |
int userId = userAccountRepository.selectUserIdByRetailerId(order.getRetailerId());
|
| 620 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
650 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 621 |
notificationService.sendNotification(sendNotificationModel);
|
651 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
652 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| 622 |
} else {
|
653 |
} else {
|
| 623 |
throw new ProfitMandiBusinessException("Upload File", "",
|
654 |
throw new ProfitMandiBusinessException("Upload File", "",
|
| 624 |
"No order available for " + ddm.getAirwayBIllNumber() + " airwaybill Number");
|
655 |
"No order available for " + ddm.getAirwayBIllNumber() + " airwaybill Number");
|
| 625 |
|
656 |
|
| 626 |
}
|
657 |
}
|
| Line 699... |
Line 730... |
| 699 |
order.setStatus(OrderStatus.DELIVERY_SUCCESS);
|
730 |
order.setStatus(OrderStatus.DELIVERY_SUCCESS);
|
| 700 |
order.setStatusDescription("Order Delivered");
|
731 |
order.setStatusDescription("Order Delivered");
|
| 701 |
|
732 |
|
| 702 |
}
|
733 |
}
|
| 703 |
|
734 |
|
| - |
|
735 |
com.spice.profitmandi.dao.entity.user.User user = userUserRepository
|
| - |
|
736 |
.selectById(orders.get(0).getRetailerId());
|
| - |
|
737 |
|
| - |
|
738 |
Address address = addressRepository.selectById(user.getAddressId());
|
| - |
|
739 |
|
| - |
|
740 |
String title = "Order Delivered";
|
| - |
|
741 |
|
| 704 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
742 |
SendNotificationModel sendNotificationModel = new SendNotificationModel();
|
| 705 |
sendNotificationModel.setCampaignName("Order Delivered");
|
743 |
sendNotificationModel.setCampaignName("Order Delivered");
|
| 706 |
sendNotificationModel.setTitle("Order Delivered");
|
744 |
sendNotificationModel.setTitle(title);
|
| 707 |
sendNotificationModel.setMessage(String.format("Dear partner, your SmartDukaan ORDER "
|
745 |
sendNotificationModel.setMessage(String.format("Dear partner, your SmartDukaan Order "
|
| 708 |
+ dl.getAirwayBillNumber() + "has been delivered to you in a safe, sealed bag by "
|
746 |
+ dl.getAirwayBillNumber() + "has been delivered to you in a safe, sealed bag by "
|
| 709 |
+ dl.getDeliveredBy() + "."));
|
747 |
+ dl.getDeliveredBy() + "."));
|
| 710 |
sendNotificationModel.setType("url");
|
748 |
sendNotificationModel.setType("url");
|
| 711 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
749 |
sendNotificationModel.setUrl("https://app.smartdukaan.com/pages/home/notifications");
|
| 712 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
750 |
sendNotificationModel.setExpiresat(LocalDateTime.now().plusDays(1));
|
| 713 |
sendNotificationModel.setMessageType(MessageType.notification);
|
751 |
sendNotificationModel.setMessageType(MessageType.notification);
|
| 714 |
int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
|
752 |
int userId = userAccountRepository.selectUserIdByRetailerId(orders.get(0).getRetailerId());
|
| 715 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
753 |
sendNotificationModel.setUserIds(Arrays.asList(userId));
|
| 716 |
notificationService.sendNotification(sendNotificationModel);
|
754 |
notificationService.sendNotification(sendNotificationModel);
|
| - |
|
755 |
|
| - |
|
756 |
String message = String.format("Dear partner, Your SmartDukaan Order " + dl.getAirwayBillNumber()
|
| - |
|
757 |
+ " has been delivered to you in a safe sealed bag.");
|
| - |
|
758 |
|
| - |
|
759 |
notificationService.sendWhatsappMessage(message, title, address.getPhoneNumber());
|
| - |
|
760 |
|
| 717 |
} else {
|
761 |
} else {
|
| 718 |
throw new ProfitMandiBusinessException("Upload File", "",
|
762 |
throw new ProfitMandiBusinessException("Upload File", "",
|
| 719 |
"No order available for " + dl.getAirwayBillNumber() + " airwaybill Number");
|
763 |
"No order available for " + dl.getAirwayBillNumber() + " airwaybill Number");
|
| 720 |
|
764 |
|
| 721 |
}
|
765 |
}
|