| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.service;
|
1 |
package com.spice.profitmandi.service;
|
| 2 |
|
2 |
|
| 3 |
import java.time.DayOfWeek;
|
- |
|
| 4 |
import java.time.LocalDate;
|
- |
|
| 5 |
import java.time.LocalDateTime;
|
- |
|
| 6 |
import java.util.ArrayList;
|
- |
|
| 7 |
import java.util.HashMap;
|
- |
|
| 8 |
import java.util.List;
|
- |
|
| 9 |
import java.util.Map;
|
- |
|
| 10 |
import java.util.stream.Collectors;
|
- |
|
| 11 |
|
- |
|
| 12 |
import org.apache.commons.lang.StringUtils;
|
- |
|
| 13 |
import org.springframework.beans.factory.annotation.Autowired;
|
- |
|
| 14 |
import org.springframework.stereotype.Component;
|
- |
|
| 15 |
|
- |
|
| 16 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
3 |
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
|
| 17 |
import com.spice.profitmandi.dao.entity.logistics.Provider;
|
4 |
import com.spice.profitmandi.dao.entity.logistics.Provider;
|
| 18 |
import com.spice.profitmandi.dao.entity.logistics.ProviderTat;
|
5 |
import com.spice.profitmandi.dao.entity.logistics.ProviderTat;
|
| 19 |
import com.spice.profitmandi.dao.entity.logistics.PublicHolidays;
|
- |
|
| 20 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
6 |
import com.spice.profitmandi.dao.entity.transaction.Order;
|
| 21 |
import com.spice.profitmandi.dao.model.DispatchNotificationModel;
|
7 |
import com.spice.profitmandi.dao.model.DispatchNotificationModel;
|
| 22 |
import com.spice.profitmandi.dao.repository.logistics.ProviderTatRepository;
|
8 |
import com.spice.profitmandi.dao.repository.logistics.ProviderTatRepository;
|
| 23 |
import com.spice.profitmandi.dao.repository.logistics.PublicHolidaysRepository;
|
9 |
import com.spice.profitmandi.dao.repository.logistics.PublicHolidaysRepository;
|
| 24 |
|
- |
|
| 25 |
import in.shop2020.model.v1.order.OrderStatus;
|
10 |
import in.shop2020.model.v1.order.OrderStatus;
|
| - |
|
11 |
import org.apache.commons.lang.StringUtils;
|
| - |
|
12 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
13 |
import org.springframework.stereotype.Component;
|
| - |
|
14 |
|
| - |
|
15 |
import java.time.DayOfWeek;
|
| - |
|
16 |
import java.time.LocalDate;
|
| - |
|
17 |
import java.time.LocalDateTime;
|
| - |
|
18 |
import java.util.ArrayList;
|
| - |
|
19 |
import java.util.List;
|
| - |
|
20 |
import java.util.Map;
|
| - |
|
21 |
import java.util.stream.Collectors;
|
| 26 |
|
22 |
|
| 27 |
@Component
|
23 |
@Component
|
| 28 |
public class LogisticsServiceImpl implements LogisticsService {
|
24 |
public class LogisticsServiceImpl implements LogisticsService {
|
| 29 |
|
25 |
|
| 30 |
@Autowired
|
26 |
@Autowired
|
| Line 54... |
Line 50... |
| 54 |
return currDate;
|
50 |
return currDate;
|
| 55 |
}
|
51 |
}
|
| 56 |
|
52 |
|
| 57 |
@Override
|
53 |
@Override
|
| 58 |
public Map<String, DispatchNotificationModel> markedOrderShippedDetail(List<Order> orders, Provider provider,
|
54 |
public Map<String, DispatchNotificationModel> markedOrderShippedDetail(List<Order> orders, Provider provider,
|
| 59 |
Map<String, DispatchNotificationModel> dispatchNotication, String airwaybillNo)
|
55 |
Map<String, DispatchNotificationModel> dispatchNotication, String airwaybillNo, LocalDateTime shippingTimestamp)
|
| 60 |
throws ProfitMandiBusinessException {
|
56 |
throws ProfitMandiBusinessException {
|
| 61 |
|
57 |
|
| 62 |
for (Order order : orders) {
|
58 |
for (Order order : orders) {
|
| 63 |
if (order.getStatus().equals(OrderStatus.BILLED)) {
|
59 |
if (order.getStatus().equals(OrderStatus.BILLED)) {
|
| 64 |
|
60 |
|
| Line 76... |
Line 72... |
| 76 |
order.setStatus(OrderStatus.SHIPPED_FROM_WH);
|
72 |
order.setStatus(OrderStatus.SHIPPED_FROM_WH);
|
| 77 |
order.setStatusDescription("Order shipped from warehouses");
|
73 |
order.setStatusDescription("Order shipped from warehouses");
|
| 78 |
|
74 |
|
| 79 |
ProviderTat pt = providerTatRepository.selectByProviderId(order.getLogisticsProviderId(),
|
75 |
ProviderTat pt = providerTatRepository.selectByProviderId(order.getLogisticsProviderId(),
|
| 80 |
order.getWarehouseId(), order.getRetailerPinCode());
|
76 |
order.getWarehouseId(), order.getRetailerPinCode());
|
| 81 |
order.setShippingTimestamp(LocalDateTime.now());
|
77 |
order.setShippingTimestamp(shippingTimestamp);
|
| 82 |
|
78 |
|
| 83 |
LocalDate deliveryDate = this.calculateDeliveryTimeline(LocalDate.now(), pt, 0);
|
79 |
LocalDate deliveryDate = this.calculateDeliveryTimeline(LocalDate.now(), pt, 0);
|
| 84 |
order.setExpectedDeliveryTime(deliveryDate.atStartOfDay());
|
80 |
order.setExpectedDeliveryTime(deliveryDate.atStartOfDay());
|
| 85 |
|
81 |
|
| 86 |
if (dispatchNotication.get(airwaybillNo) != null) {
|
82 |
if (dispatchNotication.get(airwaybillNo) != null) {
|