| Line 11... |
Line 11... |
| 11 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
11 |
import com.spice.profitmandi.dao.enumuration.auth.CollectionRemark;
|
| 12 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
12 |
import com.spice.profitmandi.dao.enumuration.cs.EscalationType;
|
| 13 |
import com.spice.profitmandi.dao.model.*;
|
13 |
import com.spice.profitmandi.dao.model.*;
|
| 14 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
14 |
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
|
| 15 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
15 |
import com.spice.profitmandi.dao.repository.dtr.FofoStoreRepository;
|
| - |
|
16 |
import com.spice.profitmandi.service.EmailService;
|
| 16 |
import com.spice.profitmandi.service.user.RetailerService;
|
17 |
import com.spice.profitmandi.service.user.RetailerService;
|
| 17 |
import org.apache.commons.collections4.map.HashedMap;
|
18 |
import org.apache.commons.collections4.map.HashedMap;
|
| 18 |
import org.apache.commons.lang.RandomStringUtils;
|
19 |
import org.apache.commons.lang.RandomStringUtils;
|
| 19 |
import org.apache.commons.lang.StringUtils;
|
20 |
import org.apache.commons.lang.StringUtils;
|
| 20 |
import org.apache.logging.log4j.LogManager;
|
21 |
import org.apache.logging.log4j.LogManager;
|
| Line 86... |
Line 87... |
| 86 |
private FofoStoreRepository fofoStoreRepository;
|
87 |
private FofoStoreRepository fofoStoreRepository;
|
| 87 |
|
88 |
|
| 88 |
@Autowired
|
89 |
@Autowired
|
| 89 |
private SessionFactory sessionFactory;
|
90 |
private SessionFactory sessionFactory;
|
| 90 |
|
91 |
|
| - |
|
92 |
@Autowired
|
| - |
|
93 |
EmailService emailService;
|
| - |
|
94 |
|
| - |
|
95 |
@Autowired
|
| - |
|
96 |
TicketReadStatusRepository ticketReadStatusRepository;
|
| - |
|
97 |
|
| - |
|
98 |
|
| 91 |
@Override
|
99 |
@Override
|
| 92 |
public void createTicket(int fofoId, int categoryId, int subcategoryId, String message) throws ProfitMandiBusinessException {
|
100 |
public void createTicket(int fofoId, int categoryId, int subcategoryId, String message) throws ProfitMandiBusinessException {
|
| 93 |
this.createTicket(fofoId, categoryId, subcategoryId, message, 0);
|
101 |
this.createTicket(fofoId, categoryId, subcategoryId, message, 0);
|
| 94 |
}
|
102 |
}
|
| 95 |
|
103 |
|
| Line 1747... |
Line 1755... |
| 1747 |
|
1755 |
|
| 1748 |
return result;
|
1756 |
return result;
|
| 1749 |
}
|
1757 |
}
|
| 1750 |
|
1758 |
|
| 1751 |
@Override
|
1759 |
@Override
|
| 1752 |
public Map<Integer, Boolean> getUnreadStatusForTickets(List<Ticket> tickets, int userId, UserType userType) {
|
1760 |
public Map<Integer, Boolean> getUnreadStatusForTickets(List<Ticket> tickets, int userId, TicketReadStatus.UserType userType) {
|
| 1753 |
Map<Integer, Boolean> unreadMap = new HashMap<>();
|
1761 |
Map<Integer, Boolean> unreadMap = new HashMap<>();
|
| 1754 |
if (tickets == null || tickets.isEmpty()) {
|
1762 |
if (tickets == null || tickets.isEmpty()) {
|
| 1755 |
return unreadMap;
|
1763 |
return unreadMap;
|
| 1756 |
}
|
1764 |
}
|
| 1757 |
|
1765 |
|
| Line 1773... |
Line 1781... |
| 1773 |
}
|
1781 |
}
|
| 1774 |
|
1782 |
|
| 1775 |
// Check if the current user created the last activity (exclude own updates)
|
1783 |
// Check if the current user created the last activity (exclude own updates)
|
| 1776 |
Activity lastActivity = lastActivityMap.get(ticket.getId());
|
1784 |
Activity lastActivity = lastActivityMap.get(ticket.getId());
|
| 1777 |
if (lastActivity != null) {
|
1785 |
if (lastActivity != null) {
|
| 1778 |
if (userType == UserType.AUTH_USER && lastActivity.getCreatedBy() == userId) {
|
1786 |
if (userType == TicketReadStatus.UserType.AUTH_USER && lastActivity.getCreatedBy() == userId) {
|
| 1779 |
unreadMap.put(ticket.getId(), false);
|
1787 |
unreadMap.put(ticket.getId(), false);
|
| 1780 |
continue;
|
1788 |
continue;
|
| 1781 |
}
|
1789 |
}
|
| 1782 |
if (userType == UserType.PARTNER && lastActivity.getCreatedBy() == 0
|
1790 |
if (userType == TicketReadStatus.UserType.PARTNER && lastActivity.getCreatedBy() == 0
|
| 1783 |
&& lastActivity.getType() == ActivityType.COMMUNICATION_IN) {
|
1791 |
&& lastActivity.getType() == ActivityType.COMMUNICATION_IN) {
|
| 1784 |
unreadMap.put(ticket.getId(), false);
|
1792 |
unreadMap.put(ticket.getId(), false);
|
| 1785 |
continue;
|
1793 |
continue;
|
| 1786 |
}
|
1794 |
}
|
| 1787 |
// For partners: only show as unread if activity type is external communication or resolved
|
1795 |
// For partners: only show as unread if activity type is external communication or resolved
|
| 1788 |
if (userType == UserType.PARTNER) {
|
1796 |
if (userType == TicketReadStatus.UserType.PARTNER) {
|
| 1789 |
boolean isRelevantForPartner = ActivityType.PARTNER_ACTIVITIES.contains(lastActivity.getType());
|
1797 |
boolean isRelevantForPartner = ActivityType.PARTNER_ACTIVITIES.contains(lastActivity.getType());
|
| 1790 |
unreadMap.put(ticket.getId(), isRelevantForPartner);
|
1798 |
unreadMap.put(ticket.getId(), isRelevantForPartner);
|
| 1791 |
continue;
|
1799 |
continue;
|
| 1792 |
}
|
1800 |
}
|
| 1793 |
}
|
1801 |
}
|
| Line 1796... |
Line 1804... |
| 1796 |
}
|
1804 |
}
|
| 1797 |
return unreadMap;
|
1805 |
return unreadMap;
|
| 1798 |
}
|
1806 |
}
|
| 1799 |
|
1807 |
|
| 1800 |
@Override
|
1808 |
@Override
|
| 1801 |
public void markTicketAsRead(int ticketId, int userId, UserType userType) {
|
1809 |
public void markTicketAsRead(int ticketId, int userId, TicketReadStatus.UserType userType) {
|
| 1802 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
1810 |
Ticket ticket = ticketRepository.selectById(ticketId);
|
| 1803 |
if (ticket == null) {
|
1811 |
if (ticket == null) {
|
| 1804 |
return;
|
1812 |
return;
|
| 1805 |
}
|
1813 |
}
|
| 1806 |
TicketReadStatus readStatus = new TicketReadStatus();
|
1814 |
TicketReadStatus readStatus = new TicketReadStatus();
|