| Line 29... |
Line 29... |
| 29 |
import in.shop2020.thrift.clients.PaymentClient;
|
29 |
import in.shop2020.thrift.clients.PaymentClient;
|
| 30 |
import in.shop2020.thrift.clients.TransactionClient;
|
30 |
import in.shop2020.thrift.clients.TransactionClient;
|
| 31 |
import in.shop2020.thrift.clients.UserClient;
|
31 |
import in.shop2020.thrift.clients.UserClient;
|
| 32 |
import in.shop2020.util.CRMConstants;
|
32 |
import in.shop2020.util.CRMConstants;
|
| 33 |
import in.shop2020.util.CRMConstants.EscalationMatrix;
|
33 |
import in.shop2020.util.CRMConstants.EscalationMatrix;
|
| - |
|
34 |
import in.shop2020.util.CRMConstants.PMEscalationMatrix;
|
| 34 |
import in.shop2020.utils.HelperService.Client;
|
35 |
import in.shop2020.utils.HelperService.Client;
|
| 35 |
import in.shop2020.utils.HelperServiceException;
|
36 |
import in.shop2020.utils.HelperServiceException;
|
| 36 |
import in.shop2020.utils.ModelUtils;
|
37 |
import in.shop2020.utils.ModelUtils;
|
| 37 |
|
38 |
|
| 38 |
import java.text.DateFormat;
|
39 |
import java.text.DateFormat;
|
| Line 98... |
Line 99... |
| 98 |
private String pickupExtension;
|
99 |
private String pickupExtension;
|
| 99 |
private Map<String, Long> ticketCategorycountMap;
|
100 |
private Map<String, Long> ticketCategorycountMap;
|
| 100 |
private String premises = "";
|
101 |
private String premises = "";
|
| 101 |
private String closureType = "";
|
102 |
private String closureType = "";
|
| 102 |
private String paymentId;
|
103 |
private String paymentId;
|
| - |
|
104 |
private List<Agent> crmAgents = new ArrayList<Agent>();
|
| - |
|
105 |
private List<Agent> pmAgents = new ArrayList<Agent>();
|
| 103 |
|
106 |
|
| 104 |
private HashMap<String, String> allAttachmentsForTicket;
|
107 |
private HashMap<String, String> allAttachmentsForTicket;
|
| 105 |
|
108 |
|
| 106 |
public static final List<TicketCategory> profitMandiTicketCategoryList = new ArrayList<TicketCategory>() {
|
109 |
public static final List<TicketCategory> profitMandiTicketCategoryList = new ArrayList<TicketCategory>() {
|
| 107 |
{
|
110 |
{
|
| Line 514... |
Line 517... |
| 514 |
return index();
|
517 |
return index();
|
| 515 |
}
|
518 |
}
|
| 516 |
|
519 |
|
| 517 |
public String getUnassignedTickets() {
|
520 |
public String getUnassignedTickets() {
|
| 518 |
try {
|
521 |
try {
|
| - |
|
522 |
tickets = new ArrayList<Ticket>();
|
| 519 |
crmServiceClient = new CRMClient().getClient();
|
523 |
crmServiceClient = new CRMClient().getClient();
|
| 520 |
tickets = crmServiceClient.getUnassignedTickets();
|
524 |
List<Ticket> unassignedTickets = crmServiceClient.getUnassignedTickets();
|
| - |
|
525 |
for(Ticket unassignedTicket: unassignedTickets){
|
| - |
|
526 |
if(isSaholicAndProfitMandiAllowed()){
|
| - |
|
527 |
tickets.add(unassignedTicket);
|
| - |
|
528 |
}else if(isProfitMandiAgent()){
|
| - |
|
529 |
if(profitMandiTicketCategoryList.contains(unassignedTicket.getCategory())){
|
| - |
|
530 |
tickets.add(unassignedTicket);
|
| - |
|
531 |
}
|
| - |
|
532 |
}else{
|
| - |
|
533 |
if(!profitMandiTicketCategoryList.contains(unassignedTicket.getCategory())){
|
| - |
|
534 |
tickets.add(unassignedTicket);
|
| - |
|
535 |
}
|
| - |
|
536 |
}
|
| - |
|
537 |
}
|
| 521 |
} catch (TException e) {
|
538 |
} catch (TException e) {
|
| 522 |
String errorString = "Error getting tickets for "
|
539 |
String errorString = "Error getting tickets for "
|
| 523 |
+ currentAgentEmailId;
|
540 |
+ currentAgentEmailId;
|
| 524 |
log.error(errorString, e);
|
541 |
log.error(errorString, e);
|
| 525 |
addActionError(errorString);
|
542 |
addActionError(errorString);
|
| Line 610... |
Line 627... |
| 610 |
activity.setDescription(activityDesc);
|
627 |
activity.setDescription(activityDesc);
|
| 611 |
}
|
628 |
}
|
| 612 |
|
629 |
|
| 613 |
if (ActivityType.ESCALATE_TICKET.equals(activity.getType())) {
|
630 |
if (ActivityType.ESCALATE_TICKET.equals(activity.getType())) {
|
| 614 |
log.info("Sending escalation mail");
|
631 |
log.info("Sending escalation mail");
|
| - |
|
632 |
if(escalate.startsWith("PM")){
|
| 615 |
EscalationMatrix escalation = CRMConstants.EscalationMatrix.valueOf(escalate);
|
633 |
PMEscalationMatrix escalation = CRMConstants.PMEscalationMatrix.valueOf(escalate);
|
| 616 |
List<Integer> escalationReceipients = escalation.getAgentIds();
|
634 |
List<Integer> escalationReceipients = escalation.getAgentIds();
|
| 617 |
|
- |
|
| - |
|
635 |
|
| 618 |
List<String> toMailIds = new ArrayList<String>();
|
636 |
List<String> toMailIds = new ArrayList<String>();
|
| 619 |
for (Integer agentId : escalationReceipients) {
|
637 |
for (Integer agentId : escalationReceipients) {
|
| 620 |
toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
|
638 |
toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
|
| 621 |
|
639 |
|
| 622 |
// Setting last agent as assignee
|
640 |
// Setting last agent as assignee
|
| 623 |
ticket.setAssigneeId(agentId);
|
641 |
ticket.setAssigneeId(agentId);
|
| 624 |
activity.setTicketAssigneeId(agentId);
|
642 |
activity.setTicketAssigneeId(agentId);
|
| 625 |
}
|
643 |
}
|
| 626 |
|
- |
|
| 627 |
Client helperClient = new HelperClient().getClient();
|
- |
|
| 628 |
String escalationMailSubject = createEscalationMailSubject(ticket, escalation);
|
- |
|
| 629 |
String escalationMailBody = createEscalationMailBody(ticket, escalation);
|
- |
|
| 630 |
|
644 |
|
| - |
|
645 |
Client helperClient = new HelperClient().getClient();
|
| - |
|
646 |
String escalationMailSubject = createPMEscalationMailSubject(ticket, escalation);
|
| - |
|
647 |
String escalationMailBody = createEscalationMailBody(ticket);
|
| - |
|
648 |
|
| 631 |
activity.setUserEmailId(helperClient.saveUserEmailForSending(
|
649 |
activity.setUserEmailId(helperClient.saveUserEmailForSending(
|
| 632 |
toMailIds, CRMConstants.CRM_EMAIL_SENDOR,
|
650 |
toMailIds, CRMConstants.PROFIT_MANDI_EMAIL_SENDER,
|
| 633 |
escalationMailSubject, escalationMailBody,
|
651 |
escalationMailSubject, escalationMailBody,
|
| 634 |
null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
|
652 |
null, CRMConstants.PROFIT_MANDI_EMAIL_TYPE, null, null, 1));
|
| - |
|
653 |
|
| - |
|
654 |
// We change activityType to OTHER when pop up box for email
|
| - |
|
655 |
// closes
|
| - |
|
656 |
activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
|
| - |
|
657 |
+ "Body: " + escalationMailBody);
|
| - |
|
658 |
}else{
|
| - |
|
659 |
EscalationMatrix escalation = CRMConstants.EscalationMatrix.valueOf(escalate);
|
| - |
|
660 |
List<Integer> escalationReceipients = escalation.getAgentIds();
|
| - |
|
661 |
|
| - |
|
662 |
List<String> toMailIds = new ArrayList<String>();
|
| - |
|
663 |
for (Integer agentId : escalationReceipients) {
|
| - |
|
664 |
toMailIds.add(CRMAuthorizingRealm.getAgent(agentId).getEmailId());
|
| - |
|
665 |
|
| - |
|
666 |
// Setting last agent as assignee
|
| - |
|
667 |
ticket.setAssigneeId(agentId);
|
| - |
|
668 |
activity.setTicketAssigneeId(agentId);
|
| - |
|
669 |
}
|
| - |
|
670 |
|
| - |
|
671 |
Client helperClient = new HelperClient().getClient();
|
| - |
|
672 |
String escalationMailSubject = createEscalationMailSubject(ticket, escalation);
|
| - |
|
673 |
String escalationMailBody = createEscalationMailBody(ticket);
|
| 635 |
|
674 |
|
| - |
|
675 |
activity.setUserEmailId(helperClient.saveUserEmailForSending(
|
| - |
|
676 |
toMailIds, CRMConstants.CRM_EMAIL_SENDOR,
|
| - |
|
677 |
escalationMailSubject, escalationMailBody,
|
| - |
|
678 |
null, CRMConstants.CRM_EMAIL_TYPE, null, null, 1));
|
| - |
|
679 |
|
| 636 |
// We change activityType to OTHER when pop up box for email
|
680 |
// We change activityType to OTHER when pop up box for email
|
| 637 |
// closes
|
681 |
// closes
|
| 638 |
activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
|
682 |
activity.setDescription("To: " + toMailIds + "\n\nSubject: " + escalationMailSubject + "\n\n"
|
| 639 |
+ "Body: " + escalationMailBody);
|
683 |
+ "Body: " + escalationMailBody);
|
| - |
|
684 |
}
|
| 640 |
}
|
685 |
}
|
| 641 |
|
686 |
|
| 642 |
User user = null;
|
687 |
User user = null;
|
| 643 |
userContextServiceClient = new UserClient().getClient();
|
688 |
userContextServiceClient = new UserClient().getClient();
|
| 644 |
try {
|
689 |
try {
|
| Line 683... |
Line 728... |
| 683 |
}
|
728 |
}
|
| 684 |
|
729 |
|
| 685 |
return INDEX;
|
730 |
return INDEX;
|
| 686 |
}
|
731 |
}
|
| 687 |
|
732 |
|
| 688 |
private String createEscalationMailBody(Ticket ticket,
|
733 |
private String createEscalationMailBody(Ticket ticket)
|
| 689 |
EscalationMatrix escalation)
|
- |
|
| 690 |
{
|
734 |
{
|
| 691 |
return body + "<br />Please visit following URL to check ticket details.<br />" +
|
735 |
return body + "<br />Please visit following URL to check ticket details.<br />" +
|
| 692 |
"http://cs.shop2020.in:8080/crm?ticketId=" + ticket.getId();
|
736 |
"http://cs.shop2020.in:8080/crm?ticketId=" + ticket.getId();
|
| 693 |
}
|
737 |
}
|
| 694 |
|
738 |
|
| 695 |
private String createEscalationMailSubject(Ticket ticket,
|
739 |
private String createEscalationMailSubject(Ticket ticket,
|
| 696 |
EscalationMatrix escalation)
|
740 |
EscalationMatrix escalation)
|
| 697 |
{
|
741 |
{
|
| 698 |
return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
|
742 |
return CRMConstants.CRM_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
|
| 699 |
}
|
743 |
}
|
| - |
|
744 |
|
| - |
|
745 |
private String createPMEscalationMailSubject(Ticket ticket,
|
| - |
|
746 |
PMEscalationMatrix escalation)
|
| - |
|
747 |
{
|
| - |
|
748 |
return CRMConstants.PROFIT_MANDI_SUBJECT_PREFIX_FOR_TICKET_ID + ticket.getId() + " - ESCALATION FROM CRM - Type: " + escalation.name();
|
| - |
|
749 |
}
|
| 700 |
|
750 |
|
| 701 |
private boolean pendingCODOrders(long customerId) {
|
751 |
private boolean pendingCODOrders(long customerId) {
|
| 702 |
try {
|
752 |
try {
|
| 703 |
log.info("Trying to fetch orders for " + customerId);
|
753 |
log.info("Trying to fetch orders for " + customerId);
|
| 704 |
transactionServiceClient = new TransactionClient().getClient();
|
754 |
transactionServiceClient = new TransactionClient().getClient();
|
| Line 1181... |
Line 1231... |
| 1181 |
searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
|
1231 |
searchFilter.setTicketStatuses(new ArrayList<TicketStatus>());
|
| 1182 |
searchFilter.getTicketStatuses().add(TicketStatus.OPEN);
|
1232 |
searchFilter.getTicketStatuses().add(TicketStatus.OPEN);
|
| 1183 |
searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
|
1233 |
searchFilter.getTicketStatuses().add(TicketStatus.REOPEN);
|
| 1184 |
crmServiceClient = new CRMClient().getClient();
|
1234 |
crmServiceClient = new CRMClient().getClient();
|
| 1185 |
tickets = new ArrayList<Ticket>();
|
1235 |
tickets = new ArrayList<Ticket>();
|
| 1186 |
searchFilter.setTicketCategoryList(new ArrayList<TicketCategory>());
|
1236 |
searchFilter.setTicketCategoryList(profitMandiTicketCategoryList);
|
| 1187 |
searchFilter.getTicketCategoryList().add(TicketCategory.PROFITMANDI_CASHBACK);
|
- |
|
| 1188 |
searchFilter.getTicketCategoryList().add(TicketCategory.PROFITMANDI_FEEDBACK);
|
- |
|
| 1189 |
searchFilter.getTicketCategoryList().add(TicketCategory.PROFITMANDI_ORDER_NOT_SEEN);
|
- |
|
| 1190 |
searchFilter.getTicketCategoryList().add(TicketCategory.PROFITMANDI_OTHER);
|
- |
|
| 1191 |
searchFilter.getTicketCategoryList().add(TicketCategory.PROFITMANDI_RECHARGE_ISSUE);
|
- |
|
| 1192 |
tickets.addAll(crmServiceClient.getTickets(searchFilter));
|
1237 |
tickets.addAll(crmServiceClient.getTickets(searchFilter));
|
| 1193 |
} catch (TException e) {
|
1238 |
} catch (TException e) {
|
| 1194 |
String errorString = "Error getting tickets for "
|
1239 |
String errorString = "Error getting tickets for "
|
| 1195 |
+ currentAgentEmailId;
|
1240 |
+ currentAgentEmailId;
|
| 1196 |
log.error(errorString, e);
|
1241 |
log.error(errorString, e);
|
| Line 1225... |
Line 1270... |
| 1225 |
}
|
1270 |
}
|
| 1226 |
|
1271 |
|
| 1227 |
public EscalationMatrix[] getEscalationMatrix () {
|
1272 |
public EscalationMatrix[] getEscalationMatrix () {
|
| 1228 |
return CRMConstants.EscalationMatrix.values();
|
1273 |
return CRMConstants.EscalationMatrix.values();
|
| 1229 |
}
|
1274 |
}
|
| - |
|
1275 |
|
| - |
|
1276 |
public PMEscalationMatrix[] getPMEscalationMatrix () {
|
| - |
|
1277 |
return CRMConstants.PMEscalationMatrix.values();
|
| - |
|
1278 |
}
|
| 1230 |
|
1279 |
|
| 1231 |
public String getAddress(Order order) {
|
1280 |
public String getAddress(Order order) {
|
| 1232 |
return ModelUtils.extractAddressFromOrder(order);
|
1281 |
return ModelUtils.extractAddressFromOrder(order);
|
| 1233 |
}
|
1282 |
}
|
| 1234 |
|
1283 |
|
| Line 1247... |
Line 1296... |
| 1247 |
public Agent getAgent(long agentId) throws TException {
|
1296 |
public Agent getAgent(long agentId) throws TException {
|
| 1248 |
return CRMAuthorizingRealm.getAgent(agentId);
|
1297 |
return CRMAuthorizingRealm.getAgent(agentId);
|
| 1249 |
}
|
1298 |
}
|
| 1250 |
|
1299 |
|
| 1251 |
public List<Agent> getAllAgents() {
|
1300 |
public List<Agent> getAllAgents() {
|
| 1252 |
return CRMAuthorizingRealm.getAgents();
|
1301 |
List<Agent> allagents = CRMAuthorizingRealm.getAgents();
|
| - |
|
1302 |
List<Agent> requiredAgents = new ArrayList<Agent>();
|
| - |
|
1303 |
if(isSaholicAndProfitMandiAllowed()){
|
| - |
|
1304 |
return allagents;
|
| - |
|
1305 |
} else if(isProfitMandiAgent()){
|
| - |
|
1306 |
for(Agent agent: allagents){
|
| - |
|
1307 |
if(agent.isIs_pmCrmUser()){
|
| - |
|
1308 |
requiredAgents.add(agent);
|
| - |
|
1309 |
}
|
| - |
|
1310 |
}
|
| - |
|
1311 |
return requiredAgents;
|
| - |
|
1312 |
} else{
|
| - |
|
1313 |
for(Agent agent: allagents){
|
| - |
|
1314 |
if(!agent.isIs_pmCrmUser()||agent.isIs_allAssignable()){
|
| - |
|
1315 |
requiredAgents.add(agent);
|
| - |
|
1316 |
}
|
| - |
|
1317 |
}
|
| - |
|
1318 |
return requiredAgents;
|
| - |
|
1319 |
}
|
| 1253 |
}
|
1320 |
}
|
| 1254 |
|
1321 |
|
| 1255 |
public TicketCategory[] getTicketCategories() {
|
1322 |
public TicketCategory[] getTicketCategories() {
|
| 1256 |
return TicketCategory.values();
|
1323 |
return TicketCategory.values();
|
| 1257 |
}
|
1324 |
}
|